Filtering Categories

Discussion in 'PHP' started by x232, Jul 17, 2008.

  1. #1
    Hi,

    I am trying to replicate the ebay filtering system: antiques.shop.ebay.com/items/Antiques__W0QQ_sacatZ20081

    as you can see the items on that page are being pulled in from the sub (sub/sub) categories of the main category (Antiques)

    how can i pull off the above so that a category can display items from its sub categories and show them.

    the solution needs to mysql/php driven.

    regards
    rg
     
    x232, Jul 17, 2008 IP
  2. projectWORD

    projectWORD Active Member

    Messages:
    287
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    63
    #2
    You can just have a category table detailing the categories with a uniqueid for each category. You can then have a subcategory table with subcategories with a uniqueid for each subcategory. You then have a field in the subcategory table detailing which parent category it belongs to.

    Category Table
    ID Name
    001 Antiques
    002 Automotive

    Sub Category Table
    ID Name Parent ID
    AA1 Furniture 001

    You can then join the two tables using ID in the category table against ParentID in the subcategory table therefore giving you a list of subcategorys for a choosen category.
    You can then branch further and have sub sub categories, etc.
     
    projectWORD, Jul 17, 2008 IP