| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| Senior Member | categories sub categories Tree Hey I am working on a website and im stuck on how to make a php categories and sub categories tree i can load all the categories..but i dont know how to have sub categories under them heres how my categories table look like: Category -id -name -parent -status I am looking for the best and efficient way of doing it..a script/tutorial..w.e u got ![]() also..if possible..i wana use ajax in it...2 dynamically load sub categories..etc..not that biggie right now tho.. thanks |
| |
| | #2 (permalink) |
| NamePros Regular | check these .... http://forums.devshed.com/php-develo...on-292257.html http://forums.devshed.com/php-develo...ry+subcategory http://dev.mysql.com/tech-resources/...ical-data.html i think its will solve your problem.... |
| |
| | #4 (permalink) |
| Senior Member | hey i followed the php recursion code..but i see a Blank page:S for some reason..heres the code PHP Code: Code: CREATE TABLE `category` ( `id` int(11) NOT NULL auto_increment, `name` varchar(25) NOT NULL default '', `parent` int(5) NOT NULL default '0', `status` smallint(1) NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; -- -- Dumping data for table `category` -- INSERT INTO `category` VALUES (1, 'Funny Videos', 0, 1); INSERT INTO `category` VALUES (2, 'Animation/Flash', 0, 1); INSERT INTO `category` VALUES (4, 'Test1', 1, 0); INSERT INTO `category` VALUES (5, 'Test2', 3, 0); INSERT INTO `category` VALUES (6, 'abc', 1, 0);
__________________ cPanelHosting.com-cPanel Experts For 8 Years Hosting From $4.99 And 2 Months Free Last edited by unknowngiver; 03-05-2007 at 02:48 PM. |
| |
| | #5 (permalink) |
| NamePros Regular | change the catGen function declaration from PHP Code: PHP Code: This passes the parameter by reference, so that any changes you make to it are to the same instance of the $cPath variable, and they propagate back up the chain as you pop your recursion. Also, you should declare an initial empty array before calling the function for the first time: PHP Code: |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |