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 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.
Since you need to use conditional logic to obtain the results you want, I don't think there is any way to do that in a single SELECT query. But using several queries, first to determine how many results the each query returns, should be fairly simple.
SELECT DISTINCT * FROM products WHERE category = '$same_category' AND product_id <> '$same_product_id' AND ( (price BETWEEN $price-150 AND $price+150 AND color LIKE '%$color%') OR (color LIKE '%$color%') OR (price BETWEEN $price-150 AND $price+150) ) LIMIT 3