title: PHP Search/Filter function
body: <p>I have a filter/search function on my page that consists of a maximum of 4 dropdowns, the dropdowns show dependant on what the last dropdown was...</p>
  
  <p>In my dropdowns I have 4 potential scenarios</p>
  
  <p><em><strong>Vehicle Type</em></strong></p>
  
  <pre><code>&lt;select name="vehicleType" id="vehicleType"&gt;
      &lt;option value="choose" selected="selected"&gt;Please choose&lt;/option&gt;
      &lt;option value="hgv"&gt;HGV&lt;/option&gt;
      &lt;option value="psv"&gt;PSV&lt;/option&gt;
      &lt;option value="lgv"&gt;LGV&lt;/option&gt;
      // MORE OPTIONS AVAILABLE
  &lt;/select&gt;
  </code></pre>
  
  <p><em><strong>Coverage Region</em></strong></p>
  
  <pre><code>&lt;select name="coverageRegion" id="coverageRegion"&gt;
      &lt;option value="choose" selected="selected"&gt;Please choose&lt;/option&gt;
      &lt;option value="national"&gt;National&lt;/option&gt;  
      &lt;option value="international"&gt;International&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p><em><strong>Type of Site Preferred</em></strong></p>
  
  <pre><code>&lt;select name="locationType" id="locationType"&gt;
      &lt;option value="choose" selected="selected"&gt;Please choose&lt;/option&gt;
      &lt;option value="truckstops"&gt;Truck stops at lowest price&lt;/option&gt;  
      &lt;option value="motorway"&gt;Branded motorway sites&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>For my search function im currently using 'IF' statements where I say if 'vehicleType = X and Coverage Region = X' show these results.</p>
  
  <p>I now need to add a 4th dropdown for counties however. In my counties section there will be ~50 counties and I cant realistically have an IF statement for every possible scenario as it will take far too long, What the best way of doing this? </p>
  
  <p>An example of what im currently doing with my PHP is...</p>
  
  <pre><code>   if ($_POST['vehicleType'] == 'car' &amp;&amp; $_POST['pricing'] == 'pump' ) {             
  
  
               $customkey = 'vehicleType';
               $customvalue = 'car'; 
  
               $customkey1 = 'pricing'; 
               $customvalue1 = 'pump'; 
  
               $args = array('orderby' =&gt; 'meta_value_num', 'meta_key' =&gt; 'order', 'order' =&gt; 'ASC',
              'meta_query' =&gt; array(
              array(
                  'key' =&gt; $customkey,
                  'value' =&gt; $customvalue,
                  'compare' =&gt; '='
              ),
              array(
                  'key' =&gt; $customkey1,
                  'value' =&gt; $customvalue1,
                  'compare' =&gt; '='
              )
              )
              );
  
              $query = new WP_Query( $args );// The Loop
                  $i = 0; $i = -1;
  
  while ( $query-&gt;have_posts() )
  {
      $i++;
      $query-&gt;the_post();
      if ( $keys = get_post_custom_keys() )
      {
          echo "&lt;div class='clearfix card-prod ".($i==0?'first':'')."'&gt;&lt;div class='top-dets'&gt;&lt;span class='card-title'&gt;";
          echo the_title();
          echo "&lt;/span&gt;";
  
  
  
      // Network query 
          $network_value = get_post_custom_values('srchnetwork');
          foreach ( $network_value as $key =&gt; $value ) {
          echo '&lt;span class="srch-val-"&gt;'. $value . '&lt;/span&gt;'; }// Pricing Query
          $pricing_value = get_post_custom_values('srchpricing');
          foreach ( $pricing_value as $key =&gt; $value ) {
          echo '&lt;span class="srch-val-1"&gt;'. $value . '&lt;/span&gt;'; }
  
      // Setup Query
          $setup_value = get_post_custom_values('srchsetupfee');
          foreach ( $setup_value as $key =&gt; $value ) {
          echo '&lt;span class="srch-val-2"&gt;'. $value . '&lt;/span&gt;'; }
  
      // Services Query
          $services_value = get_post_custom_values('srchservices');
          foreach ( $services_value as $key =&gt; $value ) {
          echo '&lt;span class="srch-val-3"&gt;'. $value . '&lt;/span&gt;&lt;/div&gt;'; }
  
      // Big Card Query
          $bigcard_value = get_post_custom_values('bigcard');
          foreach ( $bigcard_value as $key =&gt; $value ) {
               echo '&lt;a href="/" class="cardclick"&gt;&lt;img src="/wp-content/themes/CAFC/images/cards/'. $value . '" alt="'; }
           echo the_title() . '" /&gt;&lt;/a&gt;';
  
  
  
      echo '&lt;img src="wp-content/themes/CAFC/images/top-choice.jpg" alt="Top Choice" class="topchoice"&gt;';
  echo the_excerpt()."&lt;/div&gt;";    
  
          }
  }
  </code></pre>