I need help on how to filter data in a database. I want a filter like in the excel spreadsheet.
For example, I have this sample code on how to get data from w3school on how to select data from database. Here is my sample code:
<?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 "<table border='1'>
<tr>
<th>Colors</th>
<th>Type</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['colors'] . "</td>";
echo "<td>" . $row['type'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>

I also found this sample too in w3school, but I dont want to filter the database with a drop down.
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.
Thanks all