SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2003
    Location
    Germany
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Categorization of products

    Hi there,

    I am working on a shop which contains many products by now. So we need to do some categorization in order clients can still find what they are looking for.

    I am starting from scratch and I am looking for the best way to do this. Can somebody advise which would be the prefered way to solve this, as I have never done this before?

    E.g. I am thinking of a solution where I have an extra table containing the categories and the products id and each category is set to 0 or 1. So one field per category, or should I go with a list in one field separated by a delimiter?

    I hope you get my szenario

    Thanks for any help, best regards,

    ASchweti

  2. #2
    SitePoint Member
    Join Date
    Sep 2002
    Location
    Ohio
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would create 3 tables, one for products, one for categories and a table linking products to categories. This will allow you to have a product in multiple categories if needed. You may not need this now but if you ever do, you wont have to rework your db structure.

    Keith

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2003
    Location
    Germany
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Keith,

    we do need do have products in multiple categories already. Maybe I didn't make that clear?

    What I don't know how to do is, how clients should be able to select from multiple categories? Would your structure be able to handle this?

    Having a form where clients can choose multiple categories, would I submit those categories in an array? How could my MySQL query look like.

    Sorry for so many questions. A hint where or how to start would be fine

    Regards,

    ASchweti

  4. #4
    SitePoint Member
    Join Date
    Sep 2002
    Location
    Ohio
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your query might look something like.
    Code:
     SELECT * FROM products 
     LEFT JOIN category_product ON product.product_id = category_product.product_id
     WHERE category_product.category_in IN (2,6,7)
    This will not be the end all query, by any means, but it may give you a start.

    Keith


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
  •