Jump to content


Hot to generate a dynmic navigation menue

  • Please log in to reply
2 replies to this topic


  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 17 December 2004 - 08:54 PM

i have a problem. I need to create a database driven navigation menue. I created a MySQL database. The table called "nav" has the following fileds: id, content, url. The plan is that all the content of the table is displayed as a navigation menue on the webpage and every single menue item is assigend the link, wich is given to it in the "url" field of the MySQL Database. I mean when I put in some more menue items in the database, menue on the webpage will disply the new menue item and is using the url assignet to the filed in the database.
i st up a page, in which the content of the navigation menue is generated by a MySQl request. The URL is
I have the problem how do i achiev that new items in the database are displayed with korrekt link on the webpage?

Is this possible to do?
And if yes how?
for any help very thankfull.

Cu Stephan

#2 mastermike707

  • Members
  • PipPip
  • Member
  • 23 posts

Posted 21 December 2004 - 07:58 PM

Ok, first delete ALL of those recordsets you made, now, make one new recordset, called rs_nav, then select your connection. Now select the nav table. Under columns select all.
Now insert a repeating region for the nav section, deleting all but one of the 'global links'. make sure that it is a repeating region under server behaviors, and not under templates. Change the text 'global link', and put dynamic text there, making it content, and then select it and change it to a link, now make it a dynamic link by selecting the url field.

EDIT: if thats too complicated, I will make a easier to follow version, (with images).

#3 obsidian

  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 21 December 2004 - 09:13 PM

if you have the table for links with id, content (or link text), and url field, simply grab everything in the table, and loop through the results in your menu. then, use CSS to display everything like you want it. When a new link is added, it will just appear at the bottom of the menu:

$sql = "SELECT * FROM MenuTable";
$results = mysql_query($sql) or die();
echo "<ul id='nav'>\n"
while ($result = mysql_fetch_array($results)) {
    echo "<li><a href='".$result['url']."'>".$result['content']."</a></li>\n";
echo "</ul>\n";
that will give you all the links pointed to the right place in a nice unordered list, and all you have to do is apply a nice style sheet to get it to look right!
You can't win, you can't lose, you can't break even... you can't even get out of the game.

while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users