Welcome to WebmasterWorld Guest from 54.163.68.15

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP - Mysql Question

   
12:37 am on Aug 15, 2005 (gmt 0)

10+ Year Member



Hello all,

could anyone tip me off as to how to do this .. basically, I have a message board, and I want to show who were the most active posters during the last seven days. I have a messages table, which includes every post on the message board, the name of the person who posted, and the date in which they posted the message, in this format yyyy-mm-dd hh:mm:ss .. my question is, is there a mysql query that will show me say, the ten most active posters in the last seven days, based on this information .. thanks .. Dave

9:23 am on Aug 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



SELECT COUNT(id) AS count_posters, name
FROM posts
WHERE DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= post_date
GROUP BY name
ORDER BY count_posters DESC
LIMIT 10;

This should do the trick
Best regards
Michal Cibor

PS. I tested without the date, which is taken from here [dev.mysql.com]