我們一直在執行這個mySQL查詢和PHP。mySQL query&php?
這裏是我們的查詢:
SELECT DATE(`Checked`) AS theday, COUNT(`Download ID`) AS thecount,
`Status` AS thestatus
FROM `download`
WHERE `Checked`>= (CURRENT_DATE - INTERVAL 14 DAY)
GROUP BY theday, thestatus ORDER by theday DESC
這裏是PHP:
while ($r = mysql_fetch_array($q)){
echo "<pre>";
print_r($r);
echo "</pre>";
}
下面是一個示例輸出:
Array
(
[0] => 2011-10-10
[theday] => 2011-10-10
[1] => 1
[thecount] => 1
[2] => Downloading
[thestatus] => Downloading
)
Array
(
[0] => 2011-10-10
[theday] => 2011-10-10
[1] => 9
[thecount] => 9
[2] => Converting
[thestatus] => Converting
)
Array
(
[0] => 2011-10-10
[theday] => 2011-10-10
[1] => 2673
[thecount] => 2673
[2] => Complete
[thestatus] => Complete
)
Array
(
[0] => 2011-10-10
[theday] => 2011-10-10
[1] => 366
[thecount] => 366
[2] => Aborted
[thestatus] => Aborted
)
基本上,我們要顯示的結果類似這個,在一個while循環中,每天:
2011-10-10
Downloading: 1
Converting: 9
Complete: 2673
Aborted: 366
Error: 0
我們被困在如何執行查詢&的PHP來獲得結果顯示像這樣。
我們基本上要在上面的例子中,將循環14次(最近14天),輸出像上面的例子,所以這組每天和回聲出來,像這樣的數&狀態。
謝謝。
惡劣downvote,這是一個很好的書面質詢。 +1到計數器:) – Phil
意見建議:在'while'循環中使用'mysql_fetch_assoc($ q)'或'mysql_fetch_array($ q,MYSQL_ASSOC) – diEcho
謝謝,不知道爲什麼我被downvoted了,但是哦。 – Latox