Page 1 of 1

multi level php/mysql menu

Posted: Sun Aug 23, 2009 7:40 am
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

Re: multi level php/mysql menu

Posted: Sun Aug 23, 2009 7:45 am
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