multi level php/mysql menu

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
irandoct
Forum Newbie
Posts: 5
Joined: Sat Aug 01, 2009 2:10 am

multi level php/mysql menu

Post by irandoct »

Dear Friends,
I have a mysql table for my menu data. each menu item has a field that cotains it's parent ID field. i used ZERO (0) for top level items... i wanna create a multi level dynamic menu using my table data! i can't do that . my problem is related to loops... please help me and suggest a sample code!

Code: Select all

CREATE TABLE IF NOT EXISTS `sitemap` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `parentId` int(11) DEFAULT '0',
  `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `link` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=5 ;
can i use javascript in this case?
thank you
mansour
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: multi level php/mysql menu

Post by aceconcepts »

Javascript is the norm for this and there are lots of free scripts out there.

A good approach is to look at lists <ul><li></li></ul> etc...

Check out http://www.dynamicdrive.com
Post Reply