I have a loop outputting datbase entries below. How do I make the comma (,) echo for all records except for the last record?
<?php do { ?> <?php echo ","; ?> <?php } while ($row_get_subs_and_cats = mysql_fetch_assoc($get_subs_and_cats)); ?>
I'd try something like this (if you're using MySQL for the D😎:
$result=mysql_query($SQL); $num_rows = mysql_num_rows($result); $count=0; while ($count <= $num_rows) { $row = mysql_fetch_array($result); echo $row["field1"]; if ($count != $num_rows) { echo ", "; } $count++; }
Where do I place this in relation to my existing code?