Jump to content

[SOLVED] Need help with simple problem!!


gaza165

Recommended Posts

Hi All,

 

Im trying to seperate users online by a comma, however when it the last user i obviously dont need the comma there.

 

So fair I have got

 

Anonymous, Anonymous, Garry,

<?php
include("dbconnect.php");
$guests = mysql_query("SELECT * FROM active_users WHERE TIMESTAMPDIFF(MINUTE,last_active, CURRENT_TIMESTAMP()) < 2  ");
$num_of_guests = mysql_num_rows($guests);

if($num_of_guests == 1) {
$response = "<h4 class='active'>There is ".$num_of_guests." user online</h4>";
} elseif($num_of_guests > 1) {
$response = "<h4 class='active'>There are ".$num_of_guests." users online</h4>";
$comma = ", ";
} elseif($num_of_guests == 0) {
$response = "<h4 class='active'>There are ".$num_of_guests." users online</h4>";
}


echo $response;
while($row = mysql_fetch_array($guests)) {
$nick = $row['alias_name'];
?>


<span class="activenick"><? echo $nick ?>,</span>

<?}?>

 

Link to comment
https://forums.phpfreaks.com/topic/164643-solved-need-help-with-simple-problem/
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.