Jump to content

Parsing Hierarchical Data


GlassCasket

Recommended Posts

I read http://www.sitepoint.com/article/hierarchical-data-database and had a few questions. I posted on their forums no one seems to be able to help.

 

Great article, read it several times.

 

I have the following structure:

 

HTML Code:

- TB
    - cat a
    - cat b
        - sub-cat b
        - sub-cat b
        - sub-cat b
    - cat c

 

My table structure is 'category_id, name, lft, rgt'.

 

The category_id is linked in with my products table.

 

Any ideas how I can display my products in the following fashion:

 

HTML Code:

 

- TB
    - cat a
        - product from sub category a
    - cat b
        - sub-cat bb
            - product from sub category b
        - sub-cat bbb
            - product from sub category bbb
            - product from sub category bbb
        - sub-cat bbbb
    - cat c
        - product from sub category c

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/66880-parsing-hierarchical-data/
Share on other sites

Initially i thought using a query like this:

 

SELECT cat.category_id, cat.category_name, prod.cat_id, prod.name FROM cat, prod WHERE prod.cat_id=cat.category_id ORDER BY category_id ASC

 

but your aim is to have sub categories and stuff which makes it difficult for me. Probably someone else may resolve it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.