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  :)

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 :-)

Archived

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

×
×
  • 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.