Catagory Tree

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AaronL
    New Member
    • Jan 2007
    • 99

    Catagory Tree

    Hello, it's me again, I'm stumped.

    I have a database table that contains catagories for items. The fields in the table are catagoryid, parentid, and description. I want to make a menu that works like the following

    Main menu:
    Parent 1
    Parent 2
    Parent 3

    Lets say someone clicks on Parent 1, then I want it to look like
    Parent 1
    - Child 1
    -- A child within a child and so on
    - Child 2
    - Child 3
    Parent 2
    Parent 3

    I can't for the life of me figure out what the code logic is going to be.
  • prabirchoudhury
    New Member
    • May 2009
    • 162

    #2
    Catagory Tree Reply

    Code:
    Menu table
    +--------+--------------+-----------+----------------+
     | catid  | parent_id    | name       | description     |
     +-------+--------------+------------+----------------+
     |  1      | 0          | Parent 1 | description  |
     |  2      | 0          | Parent 2 | description  |
     |  3      | 0          | Parent 3 | description  |
     |  4      | 1          | Child 1   | description  |
     |  6      | 1          | Child 2   | description  |
     |  7      | 1          | Child 3   | description  |
     |  8      | 2          | Child  1  | description  |
     |  9      | 2          | Child  2  | description  |
     |  10     | 3          | Child 1   | description  |
     | 11      | 3          | Child  2  | description  |
    +-------+--------------+----------+----------------+
    1. first in the top level buttons
    Main menu:
    Parent 1
    Parent 2
    Parent 3

    you make parient buttons where parent_id = 0

    2. child buttons for each parent button

    when you click on each parent button pass their catid to get child buttons where parent_id = catid (clicked button's catid)

    good luck

    Comment

    Working...