1

Topic: Colored Usernames

Alright, so I've been trying to color usernames according to their specific group id within the online list. I'm not too sure if I'm approaching this properly, or not, but this is how it is set up.

Here is the end portion of my forums.php file:

$num_guests = 0;
$users = array();
$result = $db->query('SELECT o.user_id, o.ident, g.g_id FROM '.$db->prefix.'online AS o INNER JOIN '.$db->prefix.'groups AS g WHERE o.idle=0 ORDER BY o.ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error());

while ($pun_user_online = $db->fetch_assoc($result))
{
    if ($pun_user_online['user_id'] > 1) 
    {
        if($pun_user_online['g_id'] > PUN_MOD)
            $users[] = "\n\t\t\t\t".'<dd class="admin"><a class="username" href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>';
        else
            $users[] = "\n\t\t\t\t".'<dd><a class="username" href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>';
    }
    else
        ++$num_guests;
}
if($num_users > 0) 
{
?>
<div class="block">
    <div class="box">
        <div class="inbox">
        <?php echo "\t\t\t".'<dl id="onlinelist" class= "clearb">'."\n\t\t\t\t".'<dt><strong>Online: </strong></dt>'."\t\t\t\t".implode(',</dd> ', $users).'</dd>'."\n\t\t\t".'</dl>'."\n"; ?>
        </div>
    </div>
</div>

<?php
}

$footer_style = 'index';
require PUN_ROOT.'footer.php';

As you can see, I'm trying to assign a class to all administrators that appear in the online list. Now, my problem is that it seems to display the username four times in the online list after making these changes. I think it might have something to do with the way that I'm calling the information from the database ( The query that is set up ). Please, let me know.