Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7045607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:33:03+00:00 2026-05-28T02:33:03+00:00

In MySQL database, images in gallery can be assigned to a product range so

  • 0

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…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:33:04+00:00Added an answer on May 28, 2026 at 2:33 am

    is this good enough?

    SELECT * FROM `images` WHERE active = 'y' AND gallery = '1' AND (product_range_id = '1' OR product_range_id = '2' OR product_range_id = '3') LIMIT ".$showfrom.", ".$max.";
    

    edit

    $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;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a MySQL database that stores image information. Right now it only has
i can't display the image on my aspx view.. i'm using mysql as database
I have a series of images stored in a MySQL database that I am
I want to fetch blob datatype of images from MySQL database using PHP and
i have the following code that generate some images with urls associated from database:
I have a mySQL database which includes 3 tables to associate galleries with images.
I am making a gallery that uses a MySQL database (yeah I know it's
I am building a picture gallery, that uses this code to display each product
I have a JavaScript slideshow that pre-loads images out of a MySQL database and
I'm having trouble deleting images from a mysql database using php. The addition of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.