Whos online problem!
Posted: Wed Jun 09, 2004 4:35 pm
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:
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!
All the best
Joe
Code: Select all
$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>,";
}All the best
Joe