Jump to content

Got advice on "who's online" php/mysql structure?


mikenl

Recommended Posts

Hey,

 

I need to show who's online on a site. I have a table with personal data.

 

Should I make a new table with online data or will adding a timeout field to the existing table be able to carry the load of an update of that field every 1 minute or so?

 

Please advise if you have experience with this?

 

There's 25.000 rows in the table and I expect up to 500 people to be online at a time, but would like if 4000 online could work too, load wise...

 

THX  :)

Link to comment
Share on other sites

ya... its prolly faster to make a new table at that number of users...

on your login...

 

mysql_query("INSERT ... (id,name,timestamp)...");

 

then on every page...

$timeout=time()+3600; #now +1 hour
$query=mysql_query("SELECT `id` FROM ... WHERE `timestamp`<='$timeout' ");
while($row=mysql_fetch_assoc($query)){
mysql_query("DELETE FROM ... WHERE `id`='$row[id]' LIMIT 1");
}

 

so you only got people that have been online in the last hour... you can then query to build your lists accordingly :-)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.