Jump to content

editable php/mysql navigation menu


nyamtoko

Recommended Posts

Sure it is as simple as anything else with php/mysql

 

Create a table called menu's

ID | Name | Description | Link

 

And then just call the info from the db.

 

If you need sub menu's then create another table with the table_id of the main menu

 

ID | Name | Description | Link | Table_ID

 

 

Am not a so able php developer. Thanks.

 

Me neither :)

 

however at the moment let's say you output a menu for you site like this:

 

<ul>
<li>Menu Item 1</li>
<li>Menu Item 2</li>
<ul>
	<li> Sub Menu Item 1</li>
	<li> Sub Menu Item 1</li>
</ul>
<li>Menu Item 3</li>
<li>Menu Item 4</li>
</ul>

 

so instead you would create 2 tables in your database called "menu" and "submenu" and would give them the structure as above.

 

Then in the menu table enter the name of the menu item, the description of what it will link to and then the link itself.

 

In the submenu table you do the same but in the table_id field enter the ID of the Menu Item

 

e.g.

 

tbl_menu

ID | Name | Description | Link

1  | Menu 1 | This is the 1st menu | http://www.blah.com/1

2  | Menu 2 | This is the 2nd menu | http://www.blah.com/2

 

tbl_submenu

ID | Name | Description | Link | Table_ID

1  | Sub Menu 1 | the is a submenu of menu 1 | http://www.blah.com/2/1 | 2

 

you would then be able to write the code to simply display the output the contents of the tbl_menu with the out put of tbl_submenu in between.

 

If you really are unsure about how to use mySQL databases with PHP then you should have a read of some tutorials on the web first.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.