select attribute mysql

Posted by Viet Tran on Stack Overflow See other posts from Stack Overflow or by Viet Tran
Published on 2010-05-17T16:36:34Z Indexed on 2010/05/17 16:40 UTC
Read the original article Hit count: 247

Filed under:
|
|
|
|

I have there mysql table:

**product (id,name)**
1  Samsung
2  Toshiba
3  Sony

**attribute (id,name,parentid)**
1 Size 0
2 19" 1
3 17" 1
4 15" 1
5 Color 0
6 White 1
7 Black 2

**attribute2product (id,productid,attributeid)**
1 1 2
2 1 6
3 2 2
4 2 7
5 3 3
6 3 7

And listed them like:

Size

-- 19" (2 product(s))

-- 17" (1 product)

-- 15" (0 product)

Color

-- White (1 product)

-- Black (2 product(s))

Please help me to filter product, eg: when I choose the Size 19" (that product id 1 and 2 have), this will display:

Size

-- 19"

Color

-- White (1 product)

-- Black (1 product)

Thanks,

© Stack Overflow or respective owner

Related posts about filter

Related posts about product