Your Ad Here

Create Dynamic Database Driven CSS Navigation Menus with Dreamweaver, PHP and MySQL


Author: Ryan Grabenstein

This article will demonstrate an easy way to create dynamic CSS-based navigation menus that allow you to change your website navigation sitewide with one simple MySQL database update. For this example, I will be using the Chrome CSS Drop Down Menu available from Dynamic Drive. It's a free, lightweight CSS menu that is easily customizable and only uses a small amount of JavaScript.

There are other free CSS menus available such as the Suckerfish menu and other commercial menu options are available.

This article assumes the reader is somewhat familiar with Dreamweaver, PHP and MySQL. Powering your navigation menu from a database allows you to easily change your website's navigation menu simply by updating the database fields that make up the Dreamweaver recordset.

Building your site navigation using CSS also allows for quick sitewide changes via the stylesheet formatting.

The first step is to implement the CSS menu of your choice. It's useful to include several mock menu items as you style your menu so you can see how the menu will appear with multiple navigation choices. Once your menu is in place, go back and delete all but the first menu item in the HTML unordered list.

The second step is to create your MySQL database table which will power your menu. Using the MySQL manager of your choice, create a table which includes three fields: a unique auto-numbering ID field, a field which will hold the text displayed by each menu option, and a hyperlink field, which will include the link each menu item follows when clicked.

Depending on your site structure, you can use relative or absolute URLs in this field. At this point, insert data into the database table which will populate the site when loaded. For example, in the first table row, you could have the menu text "HOME" and the URL "index.php".

Next, back to Dreamweaver to set up the dynamic menu. With your page open, establish a connection to the MySQL database and create the menu recordset.

Include all database fields and don't use any filters on the data. Back in the code, find the first menu item that you left in place earlier. Highlight the text between the quotation marks after the href portion of code. Go into your bindings panel and open the recordset you created for the menu.

Click and drag the field representing the link URL field into your code where you highlighted the href link. This will create the PHP code to dynamically assign the link for each menu item. Next, highlight the code in your menu item that will display the browser text for each menu item.

Grab the corresponding recordset binding and drag it into your code. This will create the required PHP code that will dynamically display each menu item.

The last step in the process is to create the repeating region that will loop for each database table row. Simply highlight all code from the opening to the closing li tags surrounding the menu item.

Go to your server behaviors panel in Dreamweaver and select the "Repeated Region" option. Select the correctrecordset for the menu and click the radio button selecting all records. That completes the dynamic menu creation.

After uploading the page to your testing server, you will see each menu item you entered in your database displayed in your menu. The dynamically generated links will all point to the corresponding pages.

If you view the page code, you can see it renders a clean list for the menu items. The code is short and simple and very search engine friendly. For added functionality and the creation of the drop-down menus, simply create a database table that includes the sublinks and include a table field which will hold the parent table ID value.

Simply filter by ID for each main menu option, and dynamically generate the submenu the same way you did the main menu. The menu can then be included in a Dreamweaver template for inclusion on every page of your website.

When a page is added to the site, simply add the menu item and link in your database and it will appear on every page that includes the navigation menu. It doesn't get much easier than that to create dynamic database-driven CSS menus.

About the Author:
The author's Kearney, Nebraska website development company specializes in creating dynamic PHP/MySQL websites for small businesses and organizations.


Click here to View more Articles at: Invision-Graphics
Invision-Graphics Article Source:

Posted on Wednesday, September 12 @ 17:15:33 EDT by Admin
 
Options
 Return to the main page Return Home

 Print Page Print Version

 Send to a Friend Send To A Friend

 Discuss Article Discuss Article

 Related Articles Related Articles

 Search Articles Search Articles

 Stories Archive Stories Archive

 Subscribe Newsletter Subscribe Newsletter

 Syndicate Article Topic: Web Development XML News Feed

 Contact US Contact US
Syndicate Article
 My Yahoo!
 Google
 NewsGator
 Stumbleupon
 PluckIT
 Rojo
 Bloglines
 My AOL
 Blogrolling
 ENewsblog
 NewsIsFree
 NetVibes
 del.icio.us
 Technorati
 Digg This
 FeedBurner
 FeedMailer
Sponsor Advertising
Writing Community
community for fiction writing, story writing, poetry writing, writing contests, writing help, writing warnings

Text Advertising Info Text Advertising Info
Support US

Make a donation!
If you enjoy our services, make a donation today!

Google Support Ads
Related Links
More about Web Development
News by Admin


Advertise Here

Most read story about Web Development:
Create Dynamic Database Driven CSS Navigation Menus with Dreamweaver, PHP and MySQL

Article Rating
Average Score: 5
Votes: 8

Excellent

Please take a second and vote for this article:

Excellent
Very Good
Good
Regular
Bad


Book Advertising
Get this Book Now
Buy this Book Now!
Click Here
Related Categories
Technorati TagsTechnorati Tags
Comment on Article:"380" Login | Create an Account | 0 comments
The following comments are owned by the individual who posted them. Invision-Graphics is not responsible for the content or the accuracy of the following statements.
No Comments Allowed for Anonymous, please Register
Loans | Savings | Mortgages | Internet Advertising | Personal Loans
Click Here to Advertise
Affordable Hosting! http://www.invision-graphics.com/images/banners/468X60_VISIONHOSTING.gif
 Today: 17,427  Yesterday: 36,109  Total Hits: 23,059,892
Page Rendered in: 0.09s - Total Queries: 34 - MySQL DB: 17.2 mb's - Pages served in past 5 minutes: 172