runnerjp Posted June 24, 2008 Share Posted June 24, 2008 <?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 More sharing options...
kenrbnsn Posted June 24, 2008 Share Posted June 24, 2008 Are there more that one user in your database that match the "where" condition? Ken Link to comment https://forums.phpfreaks.com/topic/111661-echo-user-only-echos-out-1-user/#findComment-573151 Share on other sites More sharing options...
runnerjp Posted June 24, 2008 Author Share Posted June 24, 2008 yes there are... the where cluse is an address of the page they are on when on my website Link to comment https://forums.phpfreaks.com/topic/111661-echo-user-only-echos-out-1-user/#findComment-573169 Share on other sites More sharing options...
kenrbnsn Posted June 24, 2008 Share Posted June 24, 2008 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 Link to comment https://forums.phpfreaks.com/topic/111661-echo-user-only-echos-out-1-user/#findComment-573175 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.