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 | "; } ??? Link to comment https://forums.phpfreaks.com/topic/38729-solved-too-many/ 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); Link to comment https://forums.phpfreaks.com/topic/38729-solved-too-many/#findComment-186083 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. ??? Link to comment https://forums.phpfreaks.com/topic/38729-solved-too-many/#findComment-186086 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 />"; ?> Link to comment https://forums.phpfreaks.com/topic/38729-solved-too-many/#findComment-186089 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.