I am having trouble echoing values from an array. I am using a mysql query to create an array, $online
, containing the names of currently online users. Here is my code:
<?php
$goodbye = time() - 300;
$qry="SELECT UserName FROM Members WHERE Seen >=$goodbye";
$result=mysql_query($qry);
if($result) {
$online = mysql_fetch_assoc($result);
foreach($online as $u) {
echo $u;
echo "<br>";
}
} else {
die("Query Failed");
}
?>
When viewing this on my web page, only the first index of the array is shown (as in: if User1, User17, and User69 are all online, only User1 will appear on the list). I'm sure this is happening because I'm using echo incorrectly, but I haven't been able to figure it out yet. Any tips? Thanks.