Recursive category tree Code - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Recursive category tree Code (/showthread.php?tid=3500) |
Recursive category tree Code - El Forum - 10-06-2007 [eluser]tmsajin[/eluser] Usage :: $this->category_library->showCategories(45); output:: a select menu with all subcategories inside the specified category Code ~~~~~~~~~~~~~~~~~~~~~~~~~ i used adodb as db library , and following is the table structure. copy the following functions in either library or model and use as above. #---------------------------- # Table structure for categories #---------------------------- CREATE TABLE `categories` ( `cat_id` bigint(20) unsigned NOT NULL auto_increment,`cat_name` varchar(255) default NULL, `cat_nick` bigint(20) unsigned default NULL,`cat_description` text,`cat_parentid` bigint(20) unsigned default NULL,`cat_count` int(10) unsigned default '0',`cat_path` text,`cat_id_path` blob,PRIMARY KEY (`cat_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; #---------------------------- # Records for table categories #---------------------------- insert into categories values (45, 'Category 1', null, null, 0, 0, null, null), (46, 'Category2', null, null, 45, 0, null, null), (47, 'Category 3', null, null, 46, 0, null, null); Code: // &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Hope somebody who is in hurry , can use this. |