我的数据库是:table:orders,columns:id(int),order_status(varchar),time(timestamp),price(decimal);
我想在一个数组中每天收到所有订单价格的总和。最好的方法是什么?
我已经使用了这个,但它持续24小时,48小时,72小时......订单而不是每天(从00:00到23:59)。
$TimeBack = time() - 86400;
$Time = time();
$month = array();
for($i = 0; $i < 30; $i++){
//query just for example
$month[$i] = SELECT FROM orders WHERE `order_status` = 'Completed' AND `time` BETWEEN {$TimeBack} AND {$Time} ORDER BY `id` ASC");
$TimeBack = $TimeBack - 86400;
$Time = $Time - 86400;
}