I have a web page that displays a list of people and their nationality.
<td><?php echo $row['First_Name'] . " " . $row['Last_Name'] ?></td>
<td><?php echo $row['Country'] ?></td>
I would like to add a control to the page that allows the user to apply a filter on the country.
Any suggestions on how I should go about it?
You could make a link to the country - for instance like this:
//Change it, so it fits for your purpose
<a href="file.php?filter=country">Filter by country</a>.
And the PHP could simply look like this:
<?php
$con = mysql_connect("localhost","user","pass");
if (!$con) {
die('Could not connect to mysql server');
}
mysql_select_db("thepoolscene", $con);
$filterBy = ( isset( $_GET['filter']) ? 'country' : 'ASC');
$result = mysql_query("SELECT * FROM tblPlayers ORDER BY $filterBy");
?>