Jump to content

Collect my Online users?


Gayner

Recommended Posts

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
Share on other sites

$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
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.