Jump to content

is this the best way to do this query??


harkly

Recommended Posts

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

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.