Jump to content

multiple search parameters with mysql queries


samusk

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

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;
   
}

 

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.