v1n_vampire Posted January 13, 2012 Share Posted January 13, 2012 Hello all, I want to make a select box containing category list ordered by category name, where each category may have a parent category or endless child category. I found that the case is very similar to forum and subforum, but I don't have left_id or right_id in my table. Database table: category_id parent_id category_name description 1 0 name A this category doesn't have parent category 2 0 name B this category doesn't have parent category 3 2 name C this category is under category 2 4 1 name D this category is under category 1 5 3 name F this category is under category 3 6 3 name E this category is under category 3 Wanted result: • Name A •• Name D • Name B •• Name C ••• Name E ••• Name F Can anyone help me, please? Thank you~ Quote Link to comment https://forums.phpfreaks.com/topic/254928-nested-subcategory/ Share on other sites More sharing options...
Muddy_Funster Posted January 13, 2012 Share Posted January 13, 2012 you would need some serious coding to get that done. Your table isn't really set up properly for that kind of output. a single level + single sublevel isn't a problem, but to recusevly build a full depth tree from just a single parent folder listing isn't going to be fun. You may be lucky and one of the other guys here has some code to hand that could work, but if not that's a big ask. Quote Link to comment https://forums.phpfreaks.com/topic/254928-nested-subcategory/#findComment-1307148 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.