Listing Online Users

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

Listing Online Users

Post 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
User avatar
Trenchant
Forum Contributor
Posts: 291
Joined: Mon Nov 29, 2004 6:04 pm
Location: Web Dummy IS

Post 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.
User avatar
SystemWisdom
Forum Commoner
Posts: 69
Joined: Sat Mar 26, 2005 5:54 pm
Location: A Canadian South of the 49th Parallel

Re: Listing Online Users

Post 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..
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

how would you make a script run every 15mins? MIME?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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 ;)
Post Reply