PHP MySQL - Top 50 Rows Between...?

Jamie T

New member
Hi There,

I currently have a PHP/MySQL query script which displays the top 50 MySQL rows in the table, however, it displays the top 50 of all time. I would love a way for it to display the top 50 rows in the last 7 days. The table looks a bit like this,

-------------------------------------
| id | tag | date |
-------------------------------------
| 1 | search 1 | 05-27-2010
| 2 | search 2 | 05-27-2010
| 3 | search 3 | 05-28-2010
| 4 | search 4 | 05-29-2010
-------------------------------------

My current PHP/MySQL script looks like this (the script that grabs the top 50 of all time):

$result = mysql_query("SELECT tag, COUNT(*) FROM tags
GROUP BY tag
ORDER BY 2 DESC LIMIT 50");
 
Back
Top