試圖讓我的結果按月排序並顯示在表中。我哪裏錯了?MySQL在PHP腳本中按月排序
查詢:
mysql_query("SELECT COUNT(*), DATE_FORMAT(DATE(`dPostDateTime`), '%W, %b, %e') AS `day`, DATE(`dPostDateTime`) AS 'date' FROM `tblQA` WHERE cCategory IN ('Football','Baseball','Basketball','Hockey') AND dPostDateTime >= '2010-08-01' AND dPostDateTime <= '2011-07-31' GROUP BY `month`");
PHP代碼:
while($row = mysql_fetch_assoc($monthlyQ))
{
$printedRecords1++;
echo "<tr class='forum'>";
echo "<td class='forum'>" . $row['month'] . "</td>";
echo "<td class='forum'>" . $row['COUNT(*)'] . "</td>";
echo "</tr>";
}
for ($i = $printedRecords1; $i < $Print; $i++) {
echo "<tr class='forum'>";
echo "<td class='forum'> </td>";
echo "<td class='forum'> </td>";
echo "</tr>";
}
echo "</table></td><td>";
爲什麼不按月查詢本身排序? – 2011-05-09 21:48:56