Categories and subcategories in select list

Discussion in 'PHP' started by greatlogix, Jan 4, 2008.

  1. #1
    Look at this page.
    http://www.linksinn.com/submit.php

    I want all categories and subcategories in one select list just like on this page. Is there any tutorial or code snippet for this? Please share it with me.

    Thanks
     
    greatlogix, Jan 4, 2008 IP
  2. hogan_h

    hogan_h Peon

    Messages:
    199
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This actually is pretty easy, no wonder no one is replying, your thread makes you look lazy.

    just kidding ;)

    It depends how you defined your cats and subcats, the basic principle would be to use nested loops or recursion. For every level there would be another loop nested where you would add something like "|   " and "|___" for its subitems to option element like in the above example.

    That's all, it just requires a bit of cumbersome work and depends on your existing code, there is no universal solution, that's why not many people are gonna code it for you just like that or give you finished code.
     
    hogan_h, Jan 4, 2008 IP