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?

Link to comment
Share on other sites

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

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.