0

I'm trying to create a message board where members can post messages to other members. I'd like to have a section where it says "4 posts since Jan 2011" just like DaniWeb does. How do I get the date from the

"first row WHERE user='username'"

with PHP & MySQL? Also, I'd like to show if the user is online. Is that possible with PHP?
Thanks!

2
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by calebcook
0

Online user is difficult as users don't always log out. If you store session data in a DB or even lastpageaccess field, you can approximate if an user has been active in the last 10, 20 mins etc.

If your dates are stored in integer format (unix timestamp), you can set the target date using mktime() and see if post dates are >= to the target:

$targetdate = mktime(0,0,0,1,1,2011); //from midnight 1/1/2011 (hr,min,sec,mnth,day,yr)

Then the SQL:

SELECT count(*) FROM `table` WHERE `postdate` >= $targetdate

You can select a specific field for the count part - it may be faster (?)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.