homepage Welcome to WebmasterWorld Guest from 54.227.41.242
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP - Mysql Question
sysdomatic




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

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

 

mcibor




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

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]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved