I have a html form from there i post values as 1-3 days, 3-5 days by the header and trying to list all the table values in data table format,but i got struck by displaying the table by date difference. here is my code.
$day = 24*60*60; //seconds
$ticket_dates = $UtilObj->get_results("select date1,date2 from tickets where status=1");
foreach($ticket_dates as $dates){
$datediff = $dates->date2 - $dates->date1;
if($datediff > $day)
{
$days = round($datediff/$day,0);
}
else
{
$days = 1;
}
$date_values = str_replace(' ', '', $_REQUEST["status_filter"]);
// here its coming as 1-3days,3-5days,..
if ($date_values == '1-3days'){
$date_interval = 'and '.$days < 4;
}else if ($date_values == '3-5days'){
$date_interval = 'and '.$days < 6;
}else if($date_values == '5-8days'){
$date_interval = 'and '.$days < 9;
}else if($date_values == 'Above8days'){
$date_interval = 'and '.$days > 8;
}else {
$date_interval = '';
}
}
After this i need to display only the date difference which user select
$myquery = "SELECT t_id,t_date,t_name from t_table where 1=1 $date_interval order by t_id desc;";
Thanks in advice
You need the < number
in the variable so
$date_interval = 'and '.$days < 4;
too
$date_interval = 'and '.$days.' < 4';