Skip navigation links

MySQL Forums :: PHP :: while loop - how to remove last comma


Advanced Search

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 Clint Harris 11/30/2012 07:48PM
Re: while loop - how to remove last comma Peter Brawley 11/30/2012 08:33PM
Re: while loop - how to remove last comma Clint Harris 11/30/2012 08:40PM
Re: while loop - how to remove last comma rook deis 11/30/2012 10:33PM
Re: while loop - how to remove last comma Clint Harris 11/30/2012 11:06PM
Re: while loop - how to remove last comma Barry Galbraith 12/01/2012 04:34PM
Re: while loop - how to remove last comma Clint Harris 12/02/2012 02:56PM
Re: while loop - how to remove last comma Rick James 12/03/2012 07:49PM
Re: while loop - how to remove last comma Peter Brawley 12/01/2012 11:22AM


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.