Jump to content

multiple search parameters with mysql queries


samusk
 Share

Recommended Posts

I have a quick search form for my site. There are three parameters: horse breed, zip code, and location. Users don't have to enter all of the information, rather 1 parameter or 2 or all. My problem is I can get the code for the zip code to work, but when I go to code in the rest of the parameters the code seems to stall.

 

Anyone that can give a little light on this problem would be a great help. I have been working on this problem for days with no help.

 

Once I figure out this problem I can go on to make an advanced search with many more parameters.

 

Thanks in advance

Link to comment
Share on other sites

do this in your condition

function($x=' ',$y=' ',$z=' '){
     $query = ( sql here ) where 1=1;
  if ($x==' '){
          $query.= "and  field=cool";
   }
if ($y==' '){
          $query.= "and  field2=teng";
    }
if ($z==' '){
          $query.= "and  field3=teng84";
    }
   return $query;
   
}

 

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

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.

 Share

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