//check which faction members are online
$sql = mysql_query("SELECT * FROM ".TBL_ACTIVE_USERS."
WHERE faction=$userfaction_id ORDER BY timestamp DESC,username");
//no '' around var as it is an integer, so php doesn't expeect it to be string
$numrows = mysql_numrows($sql);//gets number of members online
if($numrows == 1){ echo 'You are the only faction member online'; }
else{
while($online = mysql_fetch_array($sql)){
echo '<a href="#" class="light_grey">'.$online['username'].'</a>';
echo ', ';
}//loops round all online users
//echoing their usernames
}
The above code works fine if only one member is online. The problem is really aesthetic reasons.
If more than one member is online, the query displays:
Administrator, System,
I was wondering how I would make it so on the last result (last member online by the while(){} clause) I could remove the comma? Is there a way of limiting the while statement to $numrows-1 or something along those lines? Then echoing the last user without the comma and space after their name?