Jump to content

[SOLVED] show users online


alohatofu

Recommended Posts

  • Replies 94
  • Created
  • Last Reply

this is so much easier working directly

 

ok updated (again)

 

<?php
$id = $_SESSION['tznUserId'];
$time=time();
$timeout=time()+(60*60); #now+1hour
mysql_query("UPDATE `surv_member` SET timestamp='$timeout' WHERE memberId='$id' LIMIT 1");

$query=mysql_query("SELECT * FROM `surv_member` WHERE `timestamp`>='$time'") or die(mysql_error());
$display = array();
while($row=mysql_fetch_array($query))
{
$display[] = $row['username'];
}

//spit out the results
mysql_close();
foreach($display as $d)
{
print "$d<br />";
}
?>

 

 

Still did not output any message =/

 

btw. I appreciate it Shaun and TEchie

ok

 

na don't use mIRC or any IRc's

 

<?php
$id = $_SESSION['tznUserId'];
mysql_query("UPDATE `surv_member` SET timestamp=NOW() WHERE memberId='$id' LIMIT 1");

$query=mysql_query("SELECT * FROM `surv_member` WHERE (`timestamp`+60*60) >=  NOW()") or die(mysql_error());
$display = array();
while($row=mysql_fetch_array($query))
{
$display[] = $row['username'];
}

//spit out the results
mysql_close();
foreach($display as $d)
{
print "$d<br />";
}
?>

correct,

 

runs by time alone if they are inactive for an hour then they are off the list,

 

$query=mysql_query("SELECT * FROM `surv_member` WHERE (`timestamp`+60*60) >=  NOW()") or die(mysql_error());

 

change (`timestamp`+60*60) to (`timestamp`+30*60) for 30 minutes etc

Oh this is used for active members for in the last hour,

 

if you want then to be removed from the list on logout

add this to the logout

 

$id = $_SESSION['tznUserId'];
mysql_query("UPDATE `surv_member` SET timestamp=NOW() WHERE memberId='$id' LIMIT 1");

 

 

Oh this would work better

<?php
$query=mysql_query("SELECT * FROM `surv_member` WHERE `timestamp` <=  (NOW()-60*60)") or die(mysql_error());
?>

 

 

 

OK well i am drained, i need sleep, catch ya later

this means then that you have not got a field in your table surv_member called 'timestamp'

don't forget case sensitive. In phpmyadmin there is an export button on the top click this and click the

bottom button Go. You will have the text for creating the database table. show it to us.

 

Desmond.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.