php中查询最近一个月的查询代码报错,请教咋办
程序员文章站
2022-06-01 11:32:47
...
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="
}
查询最近一个月的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)"
//最近一月的订单
$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="
- " ;
- ".$order_number." " ;
do{
$order_id=iconv("gb2312" , "utf-8//IGNORE" , $str["order_id"]) ;
$order_number=iconv("gb2312" , "utf-8//IGNORE" , $str["order_number"]) ;
$html_info_month.="
}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)"
相关文章
相关视频