Jump to content

echo $user only echos out 1 user


runnerjp

Recommended Posts

<?php $result = mysql_query("SELECT * FROM useronline WHERE(file='http://www.runningprofiles.com/members/index.php?page=forum&forum=$forum')");
while($row = mysql_fetch_array( $result )) {

$last_active = time() - $row['timestamp'];
$onlineuser = $row['user'];
}

if($last_active < 300) {
echo $onlineuser;
}
?>

 

how comes this code only echo 1 user :S

Link to comment
https://forums.phpfreaks.com/topic/111661-echo-user-only-echos-out-1-user/
Share on other sites

You don't have the echo contained in the "while" loop.

 

Try:

<?php
$result = mysql_query("SELECT * FROM useronline WHERE(file='http://www.runningprofiles.com/members/index.php?page=forum&forum=$forum')");
while($row = mysql_fetch_array( $result )) {
    $last_active = time() - $row['timestamp'];
    $onlineuser = $row['user'];
    if($last_active < 300) {
         echo $onlineuser;
    }
}
?>

 

This is why indented code is very helpful.

 

Ken

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.