Re: PHP - Who's Online Script Help
Most often this is done with a field which stores the timestamp of the user's last action. In every page, a query should execute(usually from an include()'d script) which updates the last action field for the user with the time of their current action. Like this (assuming $userid holds the current user's id):
UPDATE users SET lastaction = UNIX_TIMESTAMP() WHERE userid = '$userid'
Then when you want to determine who's "online", you just select the users who have been active recently. For example, to get users who had been active within the last 5 minutes you could use:
SELECT username FROM users WHERE lastaction > (UNIX_TIMESTAMP() - 300)
MySQL timestamps are in seconds, so 300 is used for 5 minutes since it's 5 * 60.
"But you have access to the greatest source of knowledge in the universe."
"Well I do talk to myself sometimes, yes."
"I'm back, and I'm bad! Obviously within certain, sensible, preset parameters"