Unlimited multilevel category list with PHP/MySQL
Posted: Mon Dec 01, 2008 1:39 am
I have a table with the following structure:
cat_id (pk)
parent_cat_id
cat_desc
With the above mentioned struct we can go for a unlimited multilevel category list. This is applicable for either a ecomm, knowledge base, faq etc kinda site.
I know I have to use recursive function to get this done like the following:
Category 1
- sub cat 1
-- sub sub cat 1
-- sub sub cat 2
- sub cat 2
-- sub sub cat 3
Category 2
- sub cat 3
-- sub sub cat 4
-- sub sub cat 5
Please help me out with the idea/concept or example code re how to do this.
cat_id (pk)
parent_cat_id
cat_desc
With the above mentioned struct we can go for a unlimited multilevel category list. This is applicable for either a ecomm, knowledge base, faq etc kinda site.
I know I have to use recursive function to get this done like the following:
Category 1
- sub cat 1
-- sub sub cat 1
-- sub sub cat 2
- sub cat 2
-- sub sub cat 3
Category 2
- sub cat 3
-- sub sub cat 4
-- sub sub cat 5
Please help me out with the idea/concept or example code re how to do this.