我有一个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;";
谢谢你的建议
您需要在变量中使用< number
$date_interval = 'and '.$days < 4;
也$date_interval = 'and '.$days.' < 4';