title: PHP - Filtering data in table
body: <p>I need help on how to filter data in a database. I want a filter like in the excel spreadsheet.</p>
  
  <p>For example, I have this sample code on how to get data from <a href="http://www.w3schools.com/php/php_mysql_select.asp" rel="nofollow noreferrer">w3school</a> on how to select data from database. Here is my sample code:</p>
  
  <pre><code> &lt;?php
  $con = mysql_connect("localhost","root","");
  if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
  
  mysql_select_db("TableTest", $con);
  
  $result = mysql_query("SELECT * FROM Colors ");
  
  echo "&lt;table border='1'&gt;
  &lt;tr&gt;
  &lt;th&gt;Colors&lt;/th&gt;
  &lt;th&gt;Type&lt;/th&gt;
  &lt;/tr&gt;";
  
  while($row = mysql_fetch_array($result))
    {
    echo "&lt;tr&gt;";
    echo "&lt;td&gt;" . $row['colors'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['type'] . "&lt;/td&gt;";
    echo "&lt;/tr&gt;";
    }
  echo "&lt;/table&gt;";
  
  mysql_close($con);
  ?&gt;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/OnNr3.png" alt="enter image description here"></p>
  
  <p>I also found this <a href="http://www.w3schools.com/php/php_ajax_database.asp" rel="nofollow noreferrer">sample</a> too in w3school, but I dont want to filter the database with a drop down. </p>
  
  <p>I'd like to make it like an excel filter. When I select the column 'Colors' to filter on 'Red', it will display only the color red. So i was wondering if anyone could help me on how to start.</p>
  
  <p>Thanks all</p>