php中查询最近一个月的查询代码报错,请问咋办
//最近一月的订单
$sql_month=select order_id , order_number from order_table where date_sub(curdate(), interval interval 1 month) var_dump($sql_month) ;
$mysql_month=mysql_query($sql_month) or die(could not query..mysql_error()) ;
$info_month=mysql_num_rows($mysql_month) ;
if($info_month==){
$html_info_month=最近一月没有订单。 ;
}
else{
$str=mysql_fetch_array($mysql_month) ;
// $html_info_month=最近一月的订单 ;
$html_info_month=
;
do{
$order_id=iconv(gb2312 , utf-8//ignore , $str[order_id]) ;
$order_number=iconv(gb2312 , utf-8//ignore , $str[order_number]) ;
$html_info_month.=.$order_number. ;
}while($str=mysql_fetch_array($mysql_month)) ;
$html_info_month.= ;
}
查询最近一个月的select语句,是正确的吗?
报错:
string(120) select order_id , order_number from order_table where date_sub(curdate(), interval interval 1 month) ------解决方案--------------------
select order_id , order_number from order_table where date > .strtotime('-1 month')
------解决方案--------------------
1 其实你只想问那句sql,那就不要贴代码了,太多了,好多人不喜欢看
2 $sql_month=select order_id , order_number from order_table where date_sub(curdate(), interval interval 1 month) = date(order_date)