Hi there,
I have built a simple CMS that is generally working well, the issue I'm having is with building dynamic navigation.

On the site the content for the individual pages is fine but getting the menu data and creating the menus is causing problems.

I have 2 possible structures that the database is already set up for, the first is calling all data out of a single table; the second is to call page content from the 'pages' table and menu data from the 'menu' table.

Regardless what way I'm calling the data I cannot all of the required data out of mySQL.

Working mySQL code:

$query = mysql_query("SELECT * FROM pages WHERE sefurl='$url'")
   or die ("I have a problem getting the information you requested"); 
   $data = mysql_fetch_array($query);
   $title = $data[title];
   $content = $data[content];

I hae re-written the mySQL query a number of ways however it constantly dies.

The menus on the site that is demanding the dynamic menus are mainMenu and productMenu, there is a colum in mySQL called menu type to handle this and seperate the menus.

I appreciate your help!

It took me around 10 hours but the winning code is, DRUM ROLL PLEASE...

$query = mysql_query("SELECT * FROM pages WHERE sefurl='$url'")
   or die ("I have a problem getting the information you requested"); 
   $data = mysql_fetch_array($query);
   $title = $data[title];
   $content = $data[content];
   	
mysql_free_result($query);

   $query = mysql_query("SELECT * FROM menu ORDER BY menuOrder ASC")
    or die ("I have a problem getting the information you requested"); 
	while($row = mysql_fetch_array($query))
   {
	  list($sefurl, $menuType, $menuName, $menuOrder) = $row;
	  if($menuType == "mainMenu") {
      $mainMenu .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font class=\"mainMenu\"><a href=\"$sefurl.html\">$menuName</a></font>\n";
	  }
	  if($menuType == "productMenu") {
      $productMenu .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font class=\"mainMenu\"><a href=\"$sefurl.html\">$menuName</a></font>\n";
	  }
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.