title: php filter with more than one dropdown without submit button
body: <p>I have a product display page and I need to filter products according to filters such as product family type etc… without having a submit button. I got the code to filter using the single drop-down list but can't use for multiple drop-down lists.</p>
  
  <p>Here's my code, code for drop-down list:</p>
  
  <pre><code>&lt;div class="col-md-3 col-sm-6 col-xs-6" id="fil" &gt;
      &lt;form method="post" id="report_filter" action="&lt;?= $_SERVER['PHP_SELF'];?&gt;" &gt;
          &lt;select name="name" onchange="document.getElementById('report_filter').submit();"&gt;
              &lt;option&gt;Product Family&lt;/option&gt;
              &lt;?php 
                  $qry="select * from productfamily";
                  $ex=mysqli_query($con,$qry);
                  while($row=mysqli_fetch_assoc($ex))
                  {
                      echo "&lt;option&gt;".$row['prod_family']."&lt;/option&gt;";
  
                  }
              ?&gt;
          &lt;/select&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  &lt;div class="col-md-3 col-sm-6 col-xs-6" id="fil"&gt;
      &lt;form method="post" id="report_filter" action="&lt;?= $_SERVER['PHP_SELF'];?&gt;" &gt;
          &lt;select name="name" onchange="document.getElementById('report_filter').submit();"&gt;
              &lt;option&gt;Surface Finish&lt;/option&gt;
              &lt;?php 
                  $qry="select * from surfacefinish";
                  $ex=mysqli_query($con,$qry);
                  while($row=mysqli_fetch_assoc($ex))
                  {
                      echo "&lt;option&gt;".$row['sur_finish']."&lt;/option&gt;";
  
                  }
              ?&gt;
          &lt;/select&gt;
      &lt;form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Code for the filter</p>
  
  <pre><code>if(isset($_POST['name'])){
      $sort = $_POST['name'];
      echo $sort;
      $qry="select * from products where prod_family='$sort' limit $start_from,$limit";
      $ex=mysqli_query($con,$qry);
      if(mysqli_num_rows($ex)&gt;0)
      {
          while($row=mysqli_fetch_assoc($ex))
          {
              echo '&lt;li&gt;
                  &lt;div id="imgwrap"&gt;
                  &lt;img src="admin/'.$row['image'].'"&gt;
                  &lt;/div&gt;
                  &lt;div class="prod_title"&gt;
                      &lt;h4&gt;'.$row['prod_family'].'&lt;/h4&gt;
                      &lt;h3&gt;'.$row['prod_name'].'&lt;/h3&gt;
  
                  &lt;/div&gt;
                  &lt;div id="hoverwrap"&gt;
                      &lt;h4 id="app"&gt;Suitable for '.$row['application'].'&lt;/h4&gt;
                      &lt;h4 id="color"&gt;Avalable Colors 1&lt;/h4&gt;
                      &lt;div class="readmorebtn"&gt;
                      &lt;a href="viewproduct.php?prodname='.$row['prod_name'].'"&gt;View Detail&lt;/a&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;  
  
              &lt;/li&gt;';
          }
      }
  }
  else {
      $qry="select * from products order by prod_id asc limit $start_from,$limit";
      $ex=mysqli_query($con,$qry);
      if(mysqli_num_rows($ex)&gt;0)
      {
          while($row=mysqli_fetch_assoc($ex))
          {
              echo '&lt;li&gt;
                  &lt;div id="imgwrap"&gt;
                  &lt;img src="admin/'.$row['image'].'"&gt;
                  &lt;/div&gt;
                  &lt;div class="prod_title"&gt;
                      &lt;h4&gt;'.$row['prod_family'].'&lt;/h4&gt;
                      &lt;h3&gt;'.$row['prod_name'].'&lt;/h3&gt;
  
                  &lt;/div&gt;
                  &lt;div id="hoverwrap"&gt;
                      &lt;h4 id="app"&gt;Suitable for '.$row['application'].'&lt;/h4&gt;
                      &lt;h4 id="color"&gt;Avalable Colors 1&lt;/h4&gt;
                      &lt;div class="readmorebtn"&gt;
                      &lt;a href="viewproduct.php?prodname='.$row['prod_name'].'"&gt;View Detail&lt;/a&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;  
  
              &lt;/li&gt;';
          }
      }
  }
  </code></pre>