the way i done it was to make a new table which stores a time stamp which gets updated everytime you change page.
then call this to see if a user is online or not on their profilepage or user list.
Code: Select all
$activeTime = time() - 300;
$sql = mysql_query("SELECT timestamp FROM user_log WHERE id='$_GET[id]'");
$active = mysql_fetch_array($sql);
if($active['timestamp'] < $activeTime){
$activeDisplay = "../images/offline.gif";
} else {
$activeDisplay = "../images/online.gif";
}
which shows a green image if they are online.
so if a user has been active in the last 5 minues they are classed as online. (i know its not the best, but am hoping to make it better

)
i also use a similar script to display the amount of users online (within the 5 minutes) in the menu bar section,
Code: Select all
$onlinetime = time() - 300;
echo mysql_num_rows(mysql_query("SELECT timestamp FROM user_log WHERE timestamp > '$onlinetime'"));
then ontop of that i have in the footer a list of all active users.
Code: Select all
$getOnline = mysql_query("SELECT username, id FROM user_list WHERE email_active='1' ORDER BY username ASC");
$activeTime = time() - 300;
print "Current users online:<br />";
while($row = mysql_fetch_array($getOnline)){
$check = mysql_query("SELECT timestamp FROM user_log WHERE id='$row[id]'");
$active = mysql_fetch_array($check);
$namecolour = mysql_fetch_array(mysql_query("SELECT name_colour FROM user_account WHERE id='$row[id]'"));
if($active['timestamp'] > $activeTime){
echo "<a href='../member/viewprofile.php?id=" . $row['id'] . "'><font color='$namecolour[name_colour]'>" . $row['username'] . "</font></a>, ";
}
}
Hope that helps you in someway or another
edit for scrteenies:
as you can see in the 1st screenie. sable has got a green light next to the name (cuz its the account im logged into lol) and the others have no light.
the name also appears in the footer, and the active user count is displayed in the side bar. (the green name has no relevance to this lol, its a mod account :p)
in screenie number 2... you can also faf about with the code to display how long ago they were last online, and if there is no record for them on the log table, it is displayed as never.