0

I am using PHP to create a filter for a gallery of hair styles for a client's website. She does a whole lot of color work, so I have a database with different cuts and colors she has done. I have the filter working for the most part, but I wanted to add a feature that I'm not sure is possible.

I have it set up so the page gallery.php?cat=colors&sub=blue would pull up the category "colors" and the subcategory "blue," as would simply gallery.php?sub=blue. However, I currently have the options as checkboxes, so if somebody wanted for example to show blue hair and blonde hair, gallery.php?sub=blue&sub=blonde would only display blonde hair. Is there an OR operator I can use in the URL to show both blue and blonde hair while hiding the rest of the images? I've tried Google searching and can't seem to find anything on the topic.

Mark Little
  • 335
  • 2
  • 10

1 Answers1

0

You can use array parameters in your URL, e.g. gallery.php?sub[]=blue&sub[]=blonde

But it's probably a better approach to simply allow a list of colors in your parameter, concatenating them with a character like ;, for example: gallery.php?sub=blue;blonde

And then in PHP you can do $colors = explode(';',$_GET['sub'])

Or any other split character instead of ; if you prefer, just avoid URL-specific chars like ? or & or # or + or space.

RocketNuts
  • 9,958
  • 11
  • 47
  • 88