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!
I have been trying to create a whos online script where the administrators are shown as blue and the normal users are shown as green. Admins have an ID of 1 while normal users have an ID of 0 and when I stitched the code together I was getting no luck out of it at all. My code go's like:
$query = "SELECT * FROM users WHERE username = '".$_SESSION['username']."'";
$result = mysql_query($query) or die("Error!");
$row = mysql_fetch_assoc($result);
$ID1 = $row['ID'];
$sql = "SELECT * FROM online WHERE level = '1'";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
while (true)
{
$row = mysql_fetch_assoc($result);
if ($row == false) break;
$useronline = $row['user'];
echo "<A href='http://www.site.com/viewprofile.php?ID=$ID1'><font color='blue'>$useronline</A>,";
}
$sql = "SELECT * FROM online WHERE level = '0'";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
while (true)
{
$row = mysql_fetch_assoc($result);
if ($row == false) break;
$useronline = $row['user'];
echo "<A href='http://www.site.com/viewprofile.php?ID=$ID1'><font color='green'>$useronline</A>,";
}
When I tested the code the results showed nothing for some reason I do not know. Can anyone help out here, I know the code is gritty but im just trying to get something up!