harkly Posted July 13, 2010 Share Posted July 13, 2010 I have a search form that has about 10 options to choose from, so some options can be blank. I am wondering what is the best way to go about creating the queries for when there are blanks? This is what I have now, it is searching based on 4 entries, I need to add more but would like to know if this is a good direction?? if (empty($zip_code)) { if ($genderPref == 3){ if(empty($smoke)) { if(empty($religion)) { // this searches when all of the above are empty $result = mysql_query(); } else{ // this search is when $religion is not empty but the rest are $result = mysql_query( searching $religion); } else{ // this search is when $smoke is not empty but the rest are $result = mysql_query( searching $smoke); } else{ // this starts the search when the $zip_code is not empty and $genderPref is still 3 if(empty($smoke)) { if(empty($religion)) { } I hope this isn't to confusing, I have attached my more detailed query [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/207625-is-this-the-best-way-to-do-this-query/ Share on other sites More sharing options...
Rifts Posted July 13, 2010 Share Posted July 13, 2010 I don't understand, you don't care of some entires are blank? or do you want everyone filled out? Link to comment https://forums.phpfreaks.com/topic/207625-is-this-the-best-way-to-do-this-query/#findComment-1085428 Share on other sites More sharing options...
harkly Posted July 13, 2010 Author Share Posted July 13, 2010 I don't care if they are blank. Link to comment https://forums.phpfreaks.com/topic/207625-is-this-the-best-way-to-do-this-query/#findComment-1085429 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.