How to crate a categoru and subcategory tree using Mysql in

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
bhallash
Forum Newbie
Posts: 4
Joined: Thu Nov 27, 2008 1:23 am

How to crate a categoru and subcategory tree using Mysql in

Post by bhallash »

hi ,
i want to to dispaly a list of categories and subcategories in a listbox so that user can easily select the right place to publish add. can any body give me idea ?
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: How to crate a categoru and subcategory tree using Mysql in

Post by alex.barylski »

Code: Select all

group_1
--------
pkid, name
 
group_2
--------
pkid, fkid, name
group_1 represents items or that group...group_2 represents names in sub-groups by association with fkid which points to the records in group_1.

A better way would be to implement an arbitrary depth tree but that is slightly more complicated and possibly overkill if all you need is two levels, like make and model.
Post Reply