Commas after a loop
<p>I want to add a comma to every username except last one. 
For example: User1, User2, User3
How do I do this? here is my code:</p>

<pre><code>$user_online_sql = $db-&gt;query("SELECT DISTINCT account_id FROM online WHERE account_id != '-1';");
$users = '';
while ($user_online_row = mysql_fetch_array($user_online_sql)) {
$users .= $user-&gt;name($user_online_row['account_id']) . ' ';
}
</code></pre>

<p>I tried the implode function but it just outputted a blank result, here is the code with the implode function: </p>

<pre><code> $user_online_sql = $db-&gt;query("SELECT DISTINCT account_id FROM online WHERE account_id != '-1';");
$users = '';
while ($user_online_row = mysql_fetch_array($user_online_sql)) {
$users .= implode(', ',$user-&gt;name($user_online_row['account_id'])) . ' ';
} 
</code></pre>
