Jump to content

array problems


doddsey_65

Recommended Posts

i have a users online section and i am using an aray and implode so the comma is displayed on every username but the last, but it displays the same usernames several times. This could be due to the switch i am using to define user group. Heres the code:

 

$online_query = $db->query("SELECT user_id, user_group, user_username
                            FROM ".DB_PREFIX."sessions");
while ($online_info = mysql_fetch_object($online_query)) {

switch($online_info->user_group)
        {
            case 1:
                $userClass = 'admin';
                break;
            case 2:
                $userClass = 'mod';
                break;
            case 3:
            case 0:
            default:
                $userClass = 'user';
                break;
        }

$users2[] = "<span class=\"{$userClass}\">{$online_info->user_username}</span>"; 

echo '<p>' . implode(', ', $users2) . '</p>';
}

 

is there something i am doing wrong?

 

Link to comment
https://forums.phpfreaks.com/topic/215670-array-problems/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.