Jump to content

[SOLVED] Generating a list of logged in users


soycharliente

Recommended Posts

Google is not my friend and I guess no one in the world knows how to do this. LOL

 

Is the best way to handle it just add a database table field that will hold that data? But then, what if they don't logout and just close their browser? I wouldn't want them to stay in the list.

 

Can anyone help me or point me to a tutorial/post/something that will help me generate a list of users that are logged in?

If you want, you can do:

 

1. Add a time field in your users table and update it each time a logged in user goes to a new page

2. Then:

 

$count_time = time();
$count_time = $count_time-900; //a difference of 15 minutes
$online_count = mysql_query("SELECT * FROM `users` WHERE `time`>=$count_time ORDER BY `page` DESC");
echo "<center><table cellspacing=3 cellpadding=3 width=300><tr><td class=bar><center><font class=barfont>Online List</td></tr>";

while($row = mysql_fetch_array($online_count)) {
$username = $row['username'];
echo "<tr><td><center> <a href=/user/$username> $username </a> </td></tr> ";


}
echo "</table>";

 

This should produce a list like:

 

Online List

marcus

yasuragi

Charlie

hxcChaos

Jakobo

ulitrexx

Caress

Ryan

sadie_bledsoe

angela

peachiekeen

Decco

cyllarus

ninjacore_xxlily

Jen

lynne

kim

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.