MySQL Forums
Forum List  »  PHP

while loop - how to remove last comma
Posted by: Clint Harris
Date: November 30, 2012 07:48PM

I have a while loop that lists all manufacturers that we sell and each is seperated like this: ,  so that there is a comma and a blank space seperating each one. Is there a way to remove the comma after the last one?

Here is my script:

<?php
include 'xxxxxx.php';
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die("Couldn't make connection.");

//List for brands carried
$manufacturers = mysql_query("SELECT * FROM manufacturers ORDER BY manufacturers_name ASC") or die(mysql_error());
while ($rrows = mysql_fetch_array($manufacturers)) { ?>
<a href="shop/index.php?main_page=index&manufacturers_id=<?php echo $rrows['manufacturers_id']?>"><?php echo $rrows['manufacturers_name']?></a>,&nbsp;
<?php } ?>

Thanks,

Clint

Options: ReplyQuote


Subject
Written By
Posted
while loop - how to remove last comma
November 30, 2012 07:48PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.