title: Returning All Results when Field is blank
body: <p>Hi I have a dropdown which is feeding value into a search form.  There are two criteria for search.  Property Category &amp; Property Subcategory.  The search is working nicely when both are selected.  Property Category has five options : Blank, Residential, Commerical, Industrial, Agricultural.. I want to structure the query so if the value is blank in property category it should show all results matching with Residential, Commercial, Industrial and Agricultural.  Currently leaving it blank gives no answers.</p>
  
  <p>I have tried two ways, using arrays, and then structuring mysql IN array.. but the problem is how to search in an array or in a variable in mysql...</p>
  
  <p>following is the html form</p>
  
  <pre><code>&lt;select class="searchpropertyinputs" name="property_category" id="property_category" onchange="subcategory('property_category', 'property_subcategory');"&gt;
      &lt;option value=""&gt;Property Type&lt;/option&gt;
      &lt;option value="Residential"&gt;Residential&lt;/option&gt;
      &lt;option value="Commercial"&gt;Commercial&lt;/option&gt;
      &lt;option value="Industrial"&gt;Industrial&lt;/option&gt;
      &lt;option value="Agricultural"&gt;Agricultural&lt;/option&gt;
  &lt;/select&gt;
  &lt;/br&gt;
  
  &lt;select class="searchpropertyinputs" name="property_subcategory" id="property_subcategory"&gt;
      &lt;option value=""&gt;Property Subtype&lt;/option&gt;
  &lt;/select&gt;
  &lt;/br&gt;
  </code></pre>
  
  <p>php</p>
  
  <pre><code>$property_category = ($_GET['property_category']);
  
  $select = $con-&gt;prepare("SELECT * FROM tbl_property WHERE (property_category='$property_category' AND property_subcategory='$property_subcategory') LIMIT {$start}, {$perPage}");
  $select-&gt;setFetchMode(PDO::FETCH_ASSOC);
  $select-&gt;execute();
  </code></pre>
  
  <p>I am trying to do the following but the problem is that if value is selected it is a variable otherwise if it is blank then it is an array.. hence structure the query is a problem</p>
  
  <pre><code>if ($property_category == ""){
  $myarray[1] = "'Residential'";
  $myarray[2] = "'Commercial'";
  $myarray[3] = "'Industrial'";
  $myarray[4] = "'Agricultural'";
  $property_category = implode(", ", $myarray);
  }
  
  $select = $con-&gt;prepare("SELECT * FROM tbl_property WHERE property_category IN ($property_category) LIMIT {$start}, {$perPage}");
  $select-&gt;setFetchMode(PDO::FETCH_ASSOC);
  $select-&gt;execute();
  $count = $select-&gt;rowCount();
  </code></pre>
  
  <p>the desired result is do the search based on user input, but if user does not select anything (blank value) then give all the results that exist in the column.</p>
  
  <p>this is not working, it is giving no results</p>
  
  <pre><code>$select = $con-&gt;prepare(
  "SELECT * FROM tbl_property 
  WHERE property_category LIKE
      CASE WHEN '$property_category' = '' 
      THEN '%'
      ELSE '$property_category'
      END CASE
      LIMIT {$start}, {$perPage}");
  $select-&gt;setFetchMode(PDO::FETCH_ASSOC);
  $select-&gt;execute();
  $count = $select-&gt;rowCount();
  </code></pre>