I've got a query that loops through some product names and puts them down on the page. As part of the loop, it adds a comma to the end, so it looks like this:
Products: Shirts, Pants, Ties, Jackets,
Notice that I'm getting a comma after the last product. Also, they are all links, so I can't use some strreplace fx or similar:
Here's my code:
<?php
$product_query = mysql_query("select * from products_table);
$row_product_query = mysql_fetch_assoc($product_query);
$totalRows_product_query = mysql_num_rows($product_query);
?>
<strong>Products: </strong>
<?php if ($totalRows_product_query > 0) { ?>
<?php do { ?>
<span><a href="link"><?php echo $row_product_query['products_name']; ?></a></span>
<strong>, </strong>
<?php } while ($row_product_query = mysql_fetch_assoc($product_query)); ?>
<?php } ?><br />
What do I need to do to make that last comma not appear?
Thanks in advance as always.
substrto remove the last comma.