Page 1 of 1
Listing Online Users
Posted: Fri Apr 15, 2005 4:40 pm
by Smackie
Can someone help me or tell me how to make it where when a user logs online it takes there name from offline table to online table??
and i need someone to help me make this code loop?
Code: Select all
<?php
include'config.php';
$sql = mysql_query("select * from home") or die(MySQL_Error());
$row = mysql_fetch_assoc($sql);
echo $row['message'];
?>
Thank you
Smackie
Posted: Fri Apr 15, 2005 4:46 pm
by Trenchant
you don't even need to move there name around. Add a column for each user that is defaultly offline. Then at the header of your page include a function wich changes the offline to online.
Then once every 15 minutes or so check who is still "online" and how long they have been for.
That reminds me you also need to have a column for the time they were recorded "online".
$sql = mysql_query("UPDATE users SET status='online' AND time='$curtime' WHERE username='$username' LIMIT 1");
something like that.
Re: Listing Online Users
Posted: Fri Apr 15, 2005 8:35 pm
by SystemWisdom
Smackie wrote:
[...]
and i need someone to help me make this code loop?
Code: Select all
<?php
include'config.php';
$sql = mysql_query("select * from home") or die(MySQL_Error());
$row = mysql_fetch_assoc($sql);
echo $row['message'];
?>
Try this:
Code: Select all
include'config.php';
$sql = mysql_query("select * from home") or die(MySQL_Error());
$iRowCount = @mysql_num_rows( $sql );
for( $i = 0; $i < $iRowCount; $i++ )
{
@mysql_data_seek( $sql, $i );
$row = mysql_fetch_assoc($sql);
echo $row['message']."\n";
}
I hope that hepls a bit..
Posted: Fri Apr 15, 2005 8:46 pm
by anthony88guy
how would you make a script run every 15mins? MIME?
Posted: Fri Apr 15, 2005 9:03 pm
by feyd
cron... if it
must run every 15 minutes... but who's online stuff, can be done on any normal page request. Online lists aren't important if no one is looking at it
