我从那里有一个html表单,我张贴的值为1-3天,3-5天的标题,并试图列出所有的表值在数据表的格式,但我被显示的表的日期差异。这是我的代码。
$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 = '';
}
}在此之后,我只需要显示用户选择的日期差异
$myquery = "SELECT t_id,t_date,t_name from t_table where 1=1 $date_interval order by t_id desc;"; 感谢您的建议
发布于 2015-07-10 14:31:00
您需要在变量中使用< number,以便
$date_interval = 'and '.$days < 4;也是
$date_interval = 'and '.$days.' < 4';https://stackoverflow.com/questions/31333895
复制相似问题