MP145 Posted January 13, 2009 Share Posted January 13, 2009 Hi guys, This is my code <?php //Connects to Database mysql_connect($dbhost,$dbuser,$dbpass) or die("Error:: can't connect to database"); $db = mysql_select_db("$dbname") or die("Unable to select db"); //Retrieves data from MySQL $data = mysql_query("SELECT * FROM botmenu ORDER BY id") or die(mysql_error()); $num=mysql_numrows($data); if ($num==0) { echo "Check Back Soon"; } else { //Puts it into an array while($bminfo = mysql_fetch_array( $data )) { //Displays the record echo '<a href="'.$bminfo['linkurl'].'">'.$bminfo['linktitle'].'</a> :: ';//Note two dots that i need to display } } ?> What this displays is : Home :: About Us :: Services :: What i intend to do is : Home :: About Us :: Services I would like to remove the :: from the last record in the mySql db. Can this be done in PHP ? Thanks Link to comment https://forums.phpfreaks.com/topic/140704-solved-removing-characters-for-the-last-record-from-database/ Share on other sites More sharing options...
premiso Posted January 13, 2009 Share Posted January 13, 2009 $display = array(); while($bminfo = mysql_fetch_array( $data )) { //Displays the record $display[] = '<a href="'.$bminfo['linkurl'].'">'.$bminfo['linktitle'].'</a>';//Note two dots that i need to display } echo implode(" :: ", $display); } Should fix it. Link to comment https://forums.phpfreaks.com/topic/140704-solved-removing-characters-for-the-last-record-from-database/#findComment-736423 Share on other sites More sharing options...
MP145 Posted January 13, 2009 Author Share Posted January 13, 2009 Thank you premiso for the reply YESSSSSSSSSS, works like a charm!!! Thank you so so much. Link to comment https://forums.phpfreaks.com/topic/140704-solved-removing-characters-for-the-last-record-from-database/#findComment-736428 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.