title: php filter by multi categories and one by one
body: <p>i'm trying with search box in php my html form have three options like below</p>
  
  <ol>
  <li>Purpose</li>
  <li>Type</li>
  <li>location</li>
  </ol>
  
  <p>i want if user select purpose data filter by purpose, if type then filter by type and if location then filter by location and if he select all categories then it filter like purpose in type in location and if not match display (Result not found!)</p>
  
  <p>i used these php queries but fail to get</p>
  
  <pre><code>$res="SELECT * FROM test WHERE purpose like %$_Post['purpose']% AND type like %$_Post['type']% AND location like %$_Post['location']%";
  
  while ($row = mysql_fetch_array($res))
  {
  
      echo $row['purpose']."&lt;/br&gt;";
  
      echo $row['type']."&lt;br&gt;";
  
      echo $row['location'];
      }
  </code></pre>
  
  <p>but this query not filter one by one it show if all selected if i use OR instead of AND then mix result found but i want Purpose in type in location </p>
  
  <p>and if not found show   Result not found</p>
  
  <p>please write complete query</p>
  
  <p>thanks</p>