title: php/mysql search table with unknown number of filters
body: <p>I've seen on many shopping websites they have search filters on the side, and you can add any number of filters and it researches the data showing only the data that matches all of the filter queries.</p>
  
  <p>As an example, if you go to ebay and look for a computer, you can filter by various specs of the computer to narrow the results.</p>
  
  <p>The problem I'm having is working out how to do this for a table that has so many fields that a user may search by.</p>
  
  <p>I have a table of Properties that I want to search by any number of parameters e.g. rent, location, etc.</p>
  
  <p>I could create search queries for each possible option e.g. <code>searchByAddress($array)</code>, <code>searchByAddressAndRent($array)</code>, etc. but that's clearly not feasible.</p>
  
  <p>Another way I could create separate queries for each field, then trigger separate search queries for each parameter i.e. <code>searchByRent($array)</code>, <code>searchByAddress($array)</code> and allow the PHP application to compute which fields are common in all resulting arrays using <a href="http://php.net/manual/en/function.array-intersect.php" rel="nofollow"><code>array_intersect</code></a>.</p>
  
  <p>But I was wondering, there must be a proper technique in achieving this. This question is a bit long-winded and I couldn't find any tutorials on it from googling.</p>
  
  <p>So my question is, what's the "right" method/technique of searching a database table with various search-filters?</p>