Jump to content

Hot to generate a dynmic navigation menue


Recommended Posts

Hi,

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

http://www.orthopaedie-samedan.ch/test_nav.../testnavdyn.php

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

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.