Hi Everyone,
I am trying to make this code work. It was working perfectly for me until I needed to add a way to display only current records and not older records.
I want to used the start_date as the field to manage if the record is equal to today or in the future. In other words, do not show records older than today. Code code is 'start_date=>CURdate()' I thought that would work?
These code is located in the Where SQL field of the general section:
Here is what I have:
<?php
$search_array = array('name', 'lineup', 'state','start_date=>CURdate()','end_date');
$where = array();
foreach ( $search_array as $search ) {
$value = JRequest::getVar($search, '' , 'post');
if ( $value ) {
$where[] = " $search LIKE '%$value%' ";
}
}
if ( !empty($where) ) {
echo " WHERE ".implode(' AND ', $where);
}?>
I am trying to make this code work. It was working perfectly for me until I needed to add a way to display only current records and not older records.
I want to used the start_date as the field to manage if the record is equal to today or in the future. In other words, do not show records older than today. Code code is 'start_date=>CURdate()' I thought that would work?
These code is located in the Where SQL field of the general section:
Here is what I have:
<?php
$search_array = array('name', 'lineup', 'state','start_date=>CURdate()','end_date');
$where = array();
foreach ( $search_array as $search ) {
$value = JRequest::getVar($search, '' , 'post');
if ( $value ) {
$where[] = " $search LIKE '%$value%' ";
}
}
if ( !empty($where) ) {
echo " WHERE ".implode(' AND ', $where);
}?>
Hi soliver
This 'start_date=>CURdate()', is a mess of MySQL and variable names and won't do anything.
You'll need to write some separate code lines to create the startdate 'where' clause.
What are the date formats in the form and the database table?
Bob
This 'start_date=>CURdate()', is a mess of MySQL and variable names and won't do anything.
You'll need to write some separate code lines to create the startdate 'where' clause.
What are the date formats in the form and the database table?
Bob
Hi Grayhead,
start_date is setup as varchar(25) in the table
start_date is setup in the form as 06.10.2009
I hope this help you help me.
Thank you in advance.
I truly appreciate your help!
Scott
start_date is setup as varchar(25) in the table
start_date is setup in the form as 06.10.2009
I hope this help you help me.
Thank you in advance.
I truly appreciate your help!
Scott
Hi soliver,
Can you save start_date as a MySQL Date or Date time field? That would make it much easier to work with. The mm.dd.yyyy format is not the easiest to unpack.
Bob
Can you save start_date as a MySQL Date or Date time field? That would make it much easier to work with. The mm.dd.yyyy format is not the easiest to unpack.
Bob
Greyhead,
Yes, I can. I will change it to a Date field.
So with that said, can you guide me to the correct solution?
Thank You. . .
Scott
Yes, I can. I will change it to a Date field.
So with that said, can you guide me to the correct solution?
Thank You. . .
Scott
Hi,
another idea is to maybe use strtotime function to compare the dates at the top of the body section and then use "continue" to skip the current row if it fails!🙄
Cheers
Max
another idea is to maybe use strtotime function to compare the dates at the top of the body section and then use "continue" to skip the current row if it fails!🙄
Cheers
Max
This topic is locked and no more replies can be posted.