如何在PHP中回显所有5天的计数值?

时间:2018-06-24 16:54:53

标签: php mysql mysqli php-mysqlidb

SELECT dateofbooking, count(id) AS total FROM participant WHERE dateofbooking >= $datepick AND 
  dateofbooking <= DATE_ADD($datepick, INTERVAL 5 DAY)GROUP BY dateofbooking;

如何在php中回显所有5天的计数值?

1 个答案:

答案 0 :(得分:0)

使用此代码

$from = date('Y-m-d');
$to = date('Y-m-d',strtotime("5 day"));
SELECT dateofbooking, count(id) AS total FROM participant WHERE `dateofbooking` BETWEEN '$from' AND '$to' GROUP BY dateofbooking;