SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Google Engineer polvero's Avatar
    Join Date
    Oct 2003
    Location
    Mountain View
    Posts
    567
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sorting multiple levels in a dropdown select box

    First off, I'm stuck on ordering the results into a dropdown menu.
    I have built a link directory like this:

    3 tables:

    l_links (contains the link_url, link_desc, link_test...)

    l_cats (contains the l_cat_name, l_cat_id, l_level)

    l_subcats (composed of a lookup...two columns that match up which categories of subcategories of what) Eg: cat_id # 5 is subcat of cat_id # 2....

    now that that is out of the way, now I can ask for your help

    in the backend, there is a (you guessed it) form to add links into the directory...part of the form there's a drop-down box where you can choose which category the link falls under.

    how do I spit it out in this fashion:

    Main Category 1
    sub a
    sub b
    Main Category 2
    sub a
    sub b
    sub-sub a
    sub c
    Main Category 3

    Meaning, first it lists them off according to their level (btw, each category has the l_level field in the DB that I mentioned...so you can tell if it's a first, second third...etc.. level directory.

    Then it lists by alphabetically...

    at first the easy thing to think of is
    Code:
    ...sql...ORDER BY l_level ASC, l_cat_name ASC
    but the thing is I need it to do a mix of the two...and not just straight up order it like that.

    Thanks in advance

  2. #2
    Google Engineer polvero's Avatar
    Join Date
    Oct 2003
    Location
    Mountain View
    Posts
    567
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    could a GROUP BY possibly be used in here?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •