I know this question has with out any doubt been asked a whole lot of times. I though can seem to find a solution. So forgive me if it’s way to simple.
The question is how do access the end of a while loop.
E.g.
while($countByMonth = mysql_fetch_array($countByMonthSet)) {
$c = $countByMonth["COUNT(id)"];
echo $c . "," ;
}
How do I manage separate each value of the while loop by a comma but of course I don’t want the comma at the end of the value.
In advance thank you very much for your help 🙂
You can:
1) Build a string, and remove the last character:
2) Build an array and use
implode()Tip: You can use aliases in your query, like:
SELECT COUNT(id) as count FROM .... Then you can access it as$countByMonth['count'], which looks cleaner IMO.