我有这个mysql表:
+--------------------+---------+-------+
| date | query | count |
|--------------------+---------+-------|
|2012-11-18 09:52:00 | Michael | 1 |
|2012-11-18 10:47:10 | Tom | 2 |
|2012-11-17 15:02:12 | John | 1 |
|2012-11-17 22:52:10 | Erik | 3 |
|2012-11-16 09:42:01 | Larry | 1 |
|2012-11-16 07:41:33 | Kate | 1 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
等等。我可以通过以下代码简单地获取结果并按日期对它们进行排序:
$queries = mysql_query("SELECT * FROM my_tables ORDER BY date DESC LIMIT 20");
while($row = mysql_fetch_array($queries)){
echo "Name ".$row['query']."";
}
但是如何显示按特定日期排序的表中的元素,如下所示:
In 2012-11-18:
Michael
Tom
In 2012-11-17:
John
Erik
In 2012-11-16:
Larry
Kate
等等。谢谢!