检索数据Mysql / Php的日期
问题描述:
我想知道如何使用php从我的数据库中检索数据,以获得今天的热门歌曲。
hey, I'm wondering how to retrieve data from my database using php to get the top songs today.
现在我只是得到了最棒的歌曲使用
Right now I'm just getting the top songs using
$result = mysql_query("SELECT tag, COUNT(*) AS the_tags FROM tags GROUP BY tag ORDER BY the_tags DESC LIMIT 16");
我也将标签表中的日期存储在格式
I am also storing the date in the tags table aswell, in the format
07-25-2010
07-25-2010
所以月 - 日 - 年
so Month - Day - Year
如何将结果限制为今天日期的标签?
How can i have it limit the results to tags with the date of today?
感谢:)
答
另一种方法:
"SELECT tag, COUNT(*) AS the_tags FROM tags WHERE `date` = '" . date('m-d-Y') . "' GROUP BY tag ORDER BY the_tags DESC LIMIT 16"
但是我更喜欢使用MySQL的日期(所以我会说看artefacto的帖子)
But I prefer to use MySQL's date (so I would say see artefacto's post)