title: How to filter Select option to ALL
body: <p>I have seen a lot of demos or sort of the same questions with the <code>Select All</code> option. But what I want is to just have a drop down that will allow me to select <code>All</code> option and not showing the entire Select box.</p>
  
  <p>Here is my sample HTML:</p>
  
  <pre><code>&lt;select name="status" id="status" style="width: 224px;"&gt;
      &lt;option value="" selected="selected"&gt;Please select...&lt;/option&gt;
      &lt;option value="All"&gt;All&lt;/option&gt;
      &lt;option value="Option1"&gt;Option1&lt;/option&gt;
      &lt;option value="Option2"&gt;Option2&lt;/option&gt;
      &lt;option value="Option3"&gt;Option3&lt;/option&gt;
      &lt;option value="Option4"&gt;Option4&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>From the code above I would want to just filter the result using the <code>All</code> option.</p>
  
  <p>So this is the page is where I filter and show the results in a table,</p>
  
  <pre><code>&lt;script&gt;
  $(document).ready(function(){
      $("#results").show();
  });
  &lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
  $(document).ready(function(){
      $("#RetrieveList").on('click',function() {
          var status = $('#status').val();
          var date = $('#Date').val();
          var date1 = $('#Date1').val();
          $.post('retrieve_status.php',{status:status, date:date, date1:date1}, function(data){
              $("#results").html(data);
          });
          return false;
      });
  });
  &lt;/script&gt;
  
  &lt;form id="form2" name="form2" method="post" action=""&gt;
      &lt;table width="941" border="0" align="center"&gt;
          &lt;tr&gt;
              &lt;th width="935" colspan="9" scope="col"&gt;Status:
                  &lt;select name="status" id="status" style="width: 224px;"&gt;
                      &lt;option value="" selected="selected"&gt;Please select...&lt;/option&gt;
                      &lt;option value="All"&gt;All&lt;/option&gt;
                      &lt;option value="Option1"&gt;Option1&lt;/option&gt;
                      &lt;option value="Option2"&gt;Option2&lt;/option&gt;
                      &lt;option value="Option3"&gt;Option3&lt;/option&gt;
                      &lt;option value="Option4"&gt;Option4&lt;/option&gt;
                  &lt;/select&gt;
                  Start Date:&lt;input type="text" name="Date" id="Date" size="8"/&gt;
                  End Date:&lt;input type="text" name="Date1" id="Date1" size="8"/&gt;
                  &lt;input name="action" type="submit" id="RetrieveList" value="Retrieve List" /&gt;
              &lt;/th&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/form&gt;
  
  &lt;div id="results"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And this is how I fetch the data, UPDATED to show the code from Adam Silenko</p>
  
  <pre><code>&lt;?php
  $servername = "localhost";
  $username = "username";
  $password = "password";
  $dbname = "myDBPDO";
  
  // check data before use it and convert from string to expected type, use try, not like here:
  $status = $_POST['status'];
  $date = $_POST['date'];
  $date1 = $_POST['date1'];
  // use valid data to select rows
  try {
      //1. connect to MySQL database
      $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
  
      //2. set the PDO error mode to exception
      $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
      //3. create query string (here is answer on your question)
      $sql = 'SELECT column1, column2, status FROM tracker WHERE 1=1';
      if ($status != 'ALL') $sql .= ' AND status = :st'; 
      $sql .= ' AND scheduled_start_date BETWEEN :d1 AND :d2';
  
      //4. prepare statement from query string
      $stmt = $conn-&gt;prepare($sql);
  
      //5. bind optional parameters
      if ($status != 'ALL') $stmt-&gt;bindParam(':st', $status);
  
      //6. bind parameters
      $stmt-&gt;bindParam(':d1', $date);
      $stmt-&gt;bindParam(':d2', $date1);
  
      //7. execute statement
      $stmt-&gt;execute();
  
      //8. returns an array containing all of the result set rows 
      $result = $stmt-&gt;fetchAll(PDO::FETCH_ASSOC);
  
      //get count of rows
      $numrow = count($result);
  
      //print array - there is many solution to print array,
      //to debug you can do: 
      print_r($result);
  
  } catch(PDOException $e) {
      echo "Error: " . $e-&gt;getMessage();
  }
  $conn = null;
  
  if($numrow == 0) 
    echo "No results found.";
  else 
    echo "Count: $numrow&lt;/br&gt;";
  {
  
  echo "&lt;table width='auto' cellpadding='1px' cellspacing='0px' border=1 align='center'&gt; 
  &lt;tr&gt; 
  &lt;th align='center'&gt;&lt;strong&gt;Column1&lt;/strong&gt;&lt;/th&gt; 
  &lt;th align='center'&gt;&lt;strong&gt;Column2&lt;/strong&gt;&lt;/th&gt; 
  &lt;th align='center'&gt;&lt;strong&gt;Status&lt;/strong&gt;&lt;/th&gt; 
  &lt;/tr&gt;";  
  
  foreach ($result as $row =&gt; $info) {
  echo "&lt;form action='retrieve_status_test1.php' method='post'&gt;";
  echo"&lt;tr&gt;"; echo  "&lt;td align='center'&gt;" . $info['column1'] . "&lt;input type=hidden name=column1 value=" . $info['column1'] . " &lt;/td&gt;"; 
  echo  "&lt;td align='center'&gt;" . $info['column2'] . "&lt;input type=hidden name=column2 value=" . $info['column2'] . " &lt;/td&gt;";  
  echo  "&lt;td align='center'&gt;" . $info['status'] . "&lt;input type=hidden name=status value=" . $info['status'] . " &lt;/td&gt;"; 
  echo "&lt;/tr&gt;";  
  echo "&lt;/form&gt;"; 
  } 
  } 
  echo "&lt;/table&gt;";  
  ?&gt;
  </code></pre>