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
Share on other sites

Since you're posting in the Dreamweaver section, I'll assume that you are using Dreamweaver. If you are open to buying an extension, there is always the [a href=\"http://www.interaktonline.com/\" target=\"_blank\"]interAKT[/a] Site Search extension you could use.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.