Related Products
Posted: Tue May 01, 2007 5:24 am
Hi,
please imagine the situation. On product page I have 3 related products, that should be most relevant to shown product.
I would rather show products that have common price and same color. If there is less than three results then show at least same color. And if it's necessary then show only products with common price.
I know possibilities, but no one uses only one mysql_query.
Is there any way to solve it?
please imagine the situation. On product page I have 3 related products, that should be most relevant to shown product.
Code: Select all
SELECT * FROM products WHERE category = '$same_category' AND product_id <> '$same_product_id' AND (price BETWEEN $price-10 AND $price+10 OR color LIKE '$color') ORDER BY RAND() DESC LIMIT 3
I know possibilities, but no one uses only one mysql_query.
Is there any way to solve it?