title: Filter SELECT box from previous SELECT box PHP - SQL Server
body: <p>I have a couple of SELECT boxes that are pulling from the database, how can I get the option that is selected in SELECT box 1 to filter the SQL in the SELECT box 2?</p>
  
  <p>EG SELECT 1 - Make (Audi, BMW) SELECT 2 - Model (A1,A3, 1 Series, 3 Series)</p>
  
  <p>I want to show that if I pick Audi from SELECT 1 that it will use Audi to fill the WHERE clause in my SQL to filter for the SELECT 2</p>
  
  <pre><code>&lt;label&gt;Manufacturer&lt;/label&gt;
  &lt;select class="select2_category form-control" data-placeholder="Choose a Category" tabindex="1" id="make" name="make" &gt;
      &lt;option value=""&gt;&lt;/option&gt;
      &lt;?php $sqlmake = odbc_exec($cnn, "SELECT DISTINCT Manufacturer FROM lkup.alldata ORDER BY Manufacturer ");
              while($manurs = odbc_fetch_array($sqlmake)) {                                                                        
                  echo '&lt;option value="'. $manurs['Manufacturer'] .'"&gt;'. $manurs['Manufacturer'] .'&lt;/option&gt;';
          }
      ?&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>From the above I've been working on this below, which returns no errors but also when you click on the SELECT returns no values in the SELECT.</p>
  
  <p>Where have I gone astray?</p>
  
  <p>My SELECT</p>
  
  <pre><code>&lt;select class="select2_category form-control" data-placeholder="Choose a Category" tabindex="1" id="model" name="model"&gt;
  &lt;option value=""&gt;&lt;/option&gt;                                                                
  &lt;/select&gt;
  &lt;script&gt;
  $(function() {
      $('.make').change(function() {
      var select = $('.model').empty();
          $.get('assets/configs/script.php', {model: $(this).val()}, function(result) {
              $.each(result, function(i, item) {
                  $('&lt;option value="' + item.value + '"&gt;' + item.name + '&lt;/option&gt;').
                      appendTo(select);
              });
          });
      });
      });
     &lt;/script&gt;
  </code></pre>
  
  <p>The script.php</p>
  
  <pre><code>&lt;?php
  session_start();
  date_default_timezone_set("Europe/London");
  error_reporting(0);    
  
  include 'config.php'; //my db settings
  
  if (isset($_GET['model'])) {      
      $model = addslashes($_GET['model']);
      $sqlmodel = odbc_exec($cnn, "SELECT DISTINCT ModelName FROM lkup.MyTable WHERE ModelName IS NOT NULL AND Make = $model ORDER BY ModelName ");
      $modelrs = array();
      while ($row = $sqlmodel-&gt;fetch_assoc()) {
          $modelrs[] = array(
              'ModelName' =&gt; $modelrs['ModelName']
          );
      }
      echo json_encode($modelrs);
  }?&gt; 
  </code></pre>