ipwnzphp Posted February 16, 2007 Share Posted February 16, 2007 Hello, I would like to know how to remove the ending | of my mysql results. My code is below $result = mysql_query("SELECT * FROM `CATS` WHERE PING = '1'") or die(mysql_error()); while ($row = mysql_fetch_array($result)) { $ping = $row[PING_NAME]; echo "$ping | "; } ??? Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 16, 2007 Share Posted February 16, 2007 $outs = Array(); while($row = mysql_fetch_array($result)){ $outs[] = $row[PING_NAME]; } echo implode( ' | ' , $outs); Quote Link to comment Share on other sites More sharing options...
ipwnzphp Posted February 16, 2007 Author Share Posted February 16, 2007 Thanks now i got another issue. $result = mysql_query("SELECT * FROM `CATS` WHERE PING = '1'") or die(mysql_error()); $count=0; $PING = Array(); while ($row = mysql_fetch_array($result)) { $PING[] = $row[cat_name]; } if($count == "3") { $count = 0; echo "<br>"; } echo implode(' | ', $PING); $count++; its spoused to echo 3 out and then br than 3 more and its not now. ??? Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 16, 2007 Share Posted February 16, 2007 <?php $result = mysql_query("SELECT * FROM `CATS` WHERE PING = '1'") or die(mysql_error()); $count=0; $PING = Array(); while ($row = mysql_fetch_array($result)) { $PING[] = $row[cat_name]; if($count % 3 == 0) { echo implode( ' | ', $PING) . "<br />"; $PING = Array(); } $count++; } echo implode( ' | ', $PING) . "<br />"; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.