I’m using a loop to fetch records from a database. I want it so there is a comma after each record, unless it’s the last record, or if there is only one record to display.
Here’s my partial code:
while($medals = $db->fetch_array($query))
{
if($medals['post_count'] != "")
{
$requirements = $medals['post_count']." posts";
}
if($medals['time_registered'] != "")
{
$requirements .= "Registered for ".$medals['time_registered']." days";
}
if($medals['thread_count'] != "")
{
$requirements .= $medals['thread_count']." threads";
}
if($medals['num_reps'] != "")
{
$requirements .= $medals['num_reps']." positive reputations";
}
}
How can I accomplish this?
Thanks.
Or you need commas between rows?