This is what i use for who is online, you might need to modify it or improve it (ie.put all the user id into array, the printout)
Here is the function
function whoisonline()
{
session_start();
$id=session_id();
global $link,$prefix;
$time=time();
$timeout=$time-300;
$ip=$_SERVER["REMOTE_ADDR"];
@mysql_query("DELETE FROM ".$prefix."_online where online_time <$timeout",$link);
if(isset($_SESSION["uid"])){
$user=$_SESSION["uid"];
}else{
$user=0;
}
$check=@mysql_query("Select online_user,online_time FROM ".$prefix."_online where online_session='$id'",$link) or die("Error".mysql_error());
$found=@mysql_num_rows($check);
if($found==1){
mysql_query("update ".$prefix."_online set online_user='$user',online_time='$time' WHERE online_session='$id'",$link) or die("Error".mysql_error());
}else{
mysql_query("DELETE FROM ".$prefix."_online where online_session='$id' AND online_ip='$ip'",$link);
mysql_query("INSERT into ".$prefix."_online (online_user,online_session,online_time,online_ip) values('$user','$id','$time','$ip')",$link) or die("Error".mysql_error());
}
// Find number of guest online
$guestsql=@mysql_query("select count(online_user) as guest FROM ".$prefix."_online where online_user='0'",$link);
list($guest)=@mysql_fetch_row($guestsql);
// Find number of user online
$usersql=@mysql_query("select count(online_user) as user FROM ".$prefix."_online where online_user !='0'",$link);
list($user)=@mysql_fetch_row($usersql);
//*/
$who=array($guest,$user);
return $who;
}
And here is how i use it
$online=whoisonline();
echo" There are $online[guest] and $online[$user]";
[