Hello everybody,
So this might seem like a really simple thing to some of you more advanced people but it has me extremely stumped, currently I am trying to create a menu.

What I have is a mySQL database with a row called page_name I have written the following code:

<?php
/**
 * This is the main menu
 */
$result = mysql_query( "SELECT page_name FROM ms_content" )
	or die(mysql_error()); 
$num_rows = mysql_num_rows($result);
while ($get_info = mysql_fetch_row($result)){
	echo ".:";
	foreach ($get_info as $mainmenu);
	echo "</br>";}


?>

On my template page I have

<?php echo $mainmenu ?>

Now part of this is working, see I have 8 columns of information in the page_name row which is repeating the ".:" 8 times....yay that works but the problem is is that it isn't showing up where I desire it to show up at and that only one page_name is appearing.

I am curious what I am doing wrong - what makes this tricky and maybe is confusing my young newbie mind is that the $mainmenu is being called on a separate page.

Thank you for the help!

Recommended Answers

All 3 Replies

$result = mysql_query( "SELECT page_name FROM ms_content" )
	or die(mysql_error()); 
$num_rows = mysql_num_rows($result);
$mainmenu="";
while ($get_info = mysql_fetch_row($result))
{	
        $mainmenu .= ".:";	
        $mainmenu .= $get_info[0];
        $mainmenu .= "</br>";
}

Awesome thank you very much, but may I ask why you put: $mainmenu=""; in there?

Just initialize, otherwise php may give you warning.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.