In MySQL database, images in gallery can be assigned to a product range so that galleries can be filtered to only display images from a particular range.
Currently the main image gallery contains:-
$query_Cur_range_img = "SELECT * FROM `images` WHERE active = 'y' AND gallery = '1' LIMIT ".$showfrom.", ".$max;
If gallery is '1' then images are to be displayed in main gallery (ALL).
Some images are also added to product ranges from within a separate database column 'product_range_id' and the product range id's are 1, 2, or 3.
In the include file for a filtered gallery, we have:-
$query_Cur_range_img = "SELECT * FROM `images` WHERE active = 'y' AND gallery = '1' AND product_range_id = '1' LIMIT ".$showfrom.", ".$max;
This is only displaying images that ONLY are assigned to product_range_id 1 however. Some images will be displayed to product ranges 2 and 3 for example or maybe 1 and 2. I guess we need to include an OR statement? Any help with writing the query for this would be greatly appreciated please so as above, I think we need AND product_range_id = '1' (or 2 or 3) for example?
Thanks in advance.
UPDATE
I've tried the following but all this did when filtering images by rage id 1 was display images that are ONLY assigned to range id 1 (didn't include images that assigned to range id's 1 and 2 for example).
$query_Cur_range_img = "SELECT * FROM `images` WHERE active = 'y' AND gallery = '1' AND (product_range_id = '1' OR product_range_id = '1' AND product_range_id = '2' OR product_range_id = '1' AND product_range_id = '3') LIMIT ".$showfrom.", ".$max;
UPDATE - 13/01/2012
Now Resolved - Fix Below (Thanks to Elen)
$query_Cur_range_img = "SELECT * FROM images WHERE active = 'y' AND gallery = 1 AND (FIND_IN_SET('1', product_range_id) OR product_range_id = '1') LIMIT ".$showfrom.", ".$max;
And
$query_Cur_range_img = "SELECT * FROM images WHERE active = 'y' AND gallery = 1 AND (FIND_IN_SET('2', product_range_id) OR product_range_id = '2') LIMIT ".$showfrom.", ".$max;
And
$query_Cur_range_img = "SELECT * FROM images WHERE active = 'y' AND gallery = 1 AND (FIND_IN_SET('3', product_range_id) OR product_range_id = '3') LIMIT ".$showfrom.", ".$max;
As required...