1 回答

TA貢獻1812條經(jīng)驗 獲得超5個贊
像這樣做:
$finaldata = array();
$sql = "SELECT date, COUNT(*) total FROM ( SELECT * FROM Table ORDER BY date ASC) AS sub GROUP BY date";
$result = $conn->query($sql);
while ($row = $result->fetch_assoc()) {
$x_axis[] = $row['date'];
$values[] = $row['COUNT(*)'];
}
for($date = $x_axis[0]; strtotime($date) <= strtotime(end($x_axis)); ) {
$key = array_search($date, $x_axis);
$finaldata[$date] = $key === FALSE ? 0 : $values[$key];
$date = date('Y-m-d', strtotime('+1 day', strtotime($date)))
}
echo "<pre>";print_r($finaldata);die;
您的最終數(shù)據(jù)在$finaldata數(shù)組中
- 1 回答
- 0 關(guān)注
- 167 瀏覽
添加回答
舉報