Gayner Posted December 17, 2009 Share Posted December 17, 2009 How the hell do i go about doing this? lol my users table, like on some sites like this 1 at bottom u can see everyone that is online, i want to only show people that last clicked in 3minutes or less or don't show them online? But all i got is my user's table and no brain i even searched googled and tried to find a script to fetch online users but am lost,.. thx? Link to comment https://forums.phpfreaks.com/topic/185419-collect-my-online-users/ Share on other sites More sharing options...
Gayner Posted December 17, 2009 Author Share Posted December 17, 2009 $result = mysql_query("SELECT * FROM uonline WHERE session='$ses'"); $num = mysql_num_rows($result); if($num == "0"){ $result1 = mysql_query("INSERT INTO uonline (session, time)VALUES('$ses', '$time')"); }else{ $result2 = mysql_query("UPDATE uonline SET time='$time' WHERE session = '$ses'"); } $result3 = mysql_query("SELECT * FROM uonline"); $usersonline = mysql_num_rows($result3); echo "There are: <b>".$usersonline."</b> users online"; mysql_query("DELETE FROM uonline WHERE time<$timech"); ?> I got this but.... why does it use DELETE FROM ? EDIT: Now i got this it works but how do i still don't know why it uses DELETE FROM UAONLINE EACH REFRESH?? $ses = session_id(); $time = time(); $timech=$time-5; $result = mysql_query("SELECT * FROM uonline WHERE session='$ses'"); $num = mysql_num_rows($result); if($num == "0"){ $result1 = mysql_query("INSERT INTO uonline (session, time)VALUES('$ses', '$time')"); }else{ $result2 = mysql_query("UPDATE uonline SET time='$time' WHERE session = '$ses'"); } $result3 = mysql_query("SELECT * FROM uonline"); $usersonline = mysql_num_rows($result3); echo "There are: <b>".$usersonline."</b> users online"; mysql_query("DELETE FROM uonline WHERE time<$timech"); this works but why does it use DELETE query at the end? EDIT::: OK so that query deletes all the sessions after 5seconds.. but that is dumb runnning a query every refresh is there anyway i can make it so it only runs after 20seconds? or 10seconds? Link to comment https://forums.phpfreaks.com/topic/185419-collect-my-online-users/#findComment-978860 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.