View Single Post
Old 10-25-2008, 02:02 PM   #6 (permalink)
codefreek
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Default

or you could do like this xD

PHP Code:
$query "SELECT `username` FROM `users` WHERE `last_online` >= DATE_SUB(NOW(), INTERVAL 15 MINUTES)";
$result mysql_query($query);

if(
mysql_num_rows($result) === 0)
{
   echo 
"<p>No one is online.</p>";
}
else
{
   echo 
'<p>Current online users:</p><ul>';
   while(
$row mysql_fetch_assoc($result))
   {
          echo 
'<li>'$row['username'], '</li>';
   }
   echo 
'</ul>';


output on all the user sites ;)
PHP Code:
$user $_SESSION['username'];

$query sprintf("UPDATE `users` SET `last_online` = NOW() WHERE `username` = '%s'"mysql_real_escape_string($user));

mysql_query($query); 
codefreek is offline  
Reply With Quote