Jump to content

Multiple variable search, some empty


Recommended Posts

I have a database drivensite and need to add an 'advanced search' function to it. The code below seems to work, but only if I have selected a value for each of the variables. If any are left empty then the results page shows no results. Is there a way to have the results show even if one variable has had no value. I have tried using for example and 'all genres' option on the search with a value of '0' or '-1' but this does not seem to work.

SELECT *
FROM performers
WHERE gender = 'colname' AND genre LIKE '%colgenre%' AND voicetype LIKE '%colvoice'
ORDER BY name ASC


Also, I am using drop-down lists at the moment. How can I set up the search to use multiple checkboxes for 'genre' and search for ANY of the selected - e.g. if you tick 'documentary' and 'corporate' it will look for both of those values in the 'genre' column, as well as the other variables.

Hope you can help. I am new to database driven sites and this project has snowballed!
Link to comment
https://forums.phpfreaks.com/topic/11988-multiple-variable-search-some-empty/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.