This is a simple PHP script to generate a Category Tree structure based on parent/child MySQL database. Database structure looks like this:
- category_id
- parent_id
- title
And will generate a structure like this:
Category 1
- Sub Category
- Sub, Sub Category
- Sub Category 2
Category 2
This is much simpler and works very well. The other code I found on this forum didn't work at all and was very complicated, so I wrote an easy script. Just 1 note: It's meant for a structure that does not have a root element.
- category_id
- parent_id
- title
And will generate a structure like this:
Category 1
- Sub Category
- Sub, Sub Category
- Sub Category 2
Category 2
This is much simpler and works very well. The other code I found on this forum didn't work at all and was very complicated, so I wrote an easy script. Just 1 note: It's meant for a structure that does not have a root element.
No comments:
Post a Comment