Software Developer.
Tawasul Telecom
Kuwait Free Zone, Block C-28, D9, Shuwaik, Kuwait
Phone: +965 2295 7164
Mobile:Â +965 6708 53 95
www.tawasultele.com
From: Muhammad Rizwan Nawaz <rizwan_nawaz786@...>
To: phpresource@yahoogroups.com
Sent: Monday, June 8, 2009 6:35:43 AM
Subject: RE: [phpResource] multilevel categories
Hi,
Top most element don't have parent so it's partent_id is 0. Your first query is
Select * from hosp_categories where parent_id = '0'
This will give you the top elements which you can loop and shows in <select. Once the user select any of the element in Top <select you have to pass it's id in query string and run the following query to load the child,
select * from hosp_categories where parent_id = '$ID FROM QUERY STRING'
This will give you the list of child of selected which you can easily show in <select. Same procedure is follow for next level of category. You can go till n level with this approach.
Thanks
Best Regards,
Muhammad Rizwan Nawaz
Email / MSN Messenger: rizwan_nawaz786@ hotmail.com
Gmail: rizwannawaz@ gmail.comÂ
Yahoo IM:
rizwan051
AOL IM: riznawaz
Skype: rizwannawaz
ICQ: 442047681Â
============ =
SECURITY NOTICE
============ =
   Â
THE INFORMATION CONTAINED IN THIS TRANSMISSION IS PRIVILEGED AND CONFIDENTIAL.  IT IS INTENDED FOR THE USE OF THE INDIVIDUAL OR ENTITY NAMED ABOVE.  IF THE READER OF THIS MESSAGE IS NOT THE INTENDED RECIPIENT, YOU ARE HEREBY NOTIFIED THAT ANY DISSEMINATION, DISTRIBUTION OR COPY OF THIS COMMUNICATION IS STRICTLY PROHIBITED.
   Â
IF YOU HAVE RECEIVED THIS COMMUNICATION IN ERROR, PLEASE IMMEDIATELY NOTIFY AND RETURN THE ORIGINAL MESSAGE TO THE SENDER AND DELETE IT. THANK YOU.
To: phpresource@ yahoogroups. com
From: badr@mohamedbadr. com
Date: Sun, 7 Jun 2009 15:45:27 +0300
Subject: [phpResource] multilevel categories
I have categories table with multilevel categories I need to make the insert statement for the sub categories and sub subcategories so I need to populate a <select> box with this tree so I can insert the parent id with the new subcategory
Anyone knows how to populate this select box with the tree ??
Â
The table is here
Â
CREATE TABLE IF NOT EXISTS `hosp_categories` (
 `category_id` int(10) NOT NULL auto_increment,
 `parent_id` int(10) NOT NULL,
 `title` varchar(255) NOT NULL,
 `description` text NOT NULL,
 `image` varchar(255) NOT NULL default '',
 PRIMARY KEY (`category_id` )
) ENGINE=MyISAMÂ DEFAULT CHARSET=latin1 AUTO_INCREMENT= 7 ;
Â
Â
Lauren found her dream laptop. Find the PC that’s right for you.