Jump to content

Archived

This topic is now archived and is closed to further replies.

Deserteye

Online Users

Recommended Posts

I am wondering how to show how many users active in the past 15 min. I assume I would enter the current time in a database every page a user visits and subtract 15 from that. I don't know the best way to do this but any help would be appriciated. Could someone please tell me the best way to check for and show the users active in the past 15 min and provide sample code? Thanks

(or a link to a tut will be good lol)

Share this post


Link to post
Share on other sites
Look at:

[url=http://us3.php.net/manual/en/function.time.php]time();[/url]

Share this post


Link to post
Share on other sites
On my site i include a file on every page which updates a field called LAST_ONLINE in the MEMBERS table which contains the members general user information. Then i use the following to display the people who have been active in the last 10 minutes.


[code]$online_check = mysql_query("SELECT USERNAME FROM MEMBERS WHERE LAST_ONLINE > DATE_SUB(NOW(), INTERVAL 10 MINUTE)");
$online_num = mysql_num_rows($online_check);

for ($i = 0; $i < $online_num; $i++){

$online_result = mysql_result($online_check, $i);

echo "$online_result<br>";

}[/code]

That would output a list of people.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.