SAMS Posted December 17, 2004 Share Posted December 17, 2004 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 Quote Link to comment https://forums.phpfreaks.com/topic/2099-hot-to-generate-a-dynmic-navigation-menue/ Share on other sites More sharing options...
mastermike707 Posted December 21, 2004 Share Posted December 21, 2004 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). Quote Link to comment https://forums.phpfreaks.com/topic/2099-hot-to-generate-a-dynmic-navigation-menue/#findComment-6874 Share on other sites More sharing options...
obsidian Posted December 21, 2004 Share Posted December 21, 2004 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! Quote Link to comment https://forums.phpfreaks.com/topic/2099-hot-to-generate-a-dynmic-navigation-menue/#findComment-6877 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.