Hope you are still interested in help for this :-).
First wrap your select element in form tags and set method (GET) and action (# -> self). Then add a submit button so the form can be submitted (or make the select element autosubmit).
// add <form> tags and a submit button
$submit = '<input type="submit" name="submit" value="Submit" />';
echo '<form method="get" action="#">' . $dropdown . $submit . '</form>'; Next checkfor the existence of a $_GET['Test'] value in a $_GET array. If it exists the form was submitted and you can use the selected value of the select element to filter the results (use it with WHERE clause in your query).
// if the form was submited
if(isset($_GET['Test'])) {
// sanitize test somehow
$test = $_GET['Test'];
// add the filter condition to your query
$test_query .= " WHERE test=$test";
} Your code above modified to filter results:
<?php header('Refresh: 30'); ?>
<?php
// query to show all results
$test_query = "SELECT * FROM scores";
// if the form was submited
if(isset($_GET['Test'])) {
// sanitize test somehow
$test = $_GET['Test'];
// add the filter condition to your query
$test_query .= " WHERE test=$test";
}
$con = mysql_connect("localhost","test","test");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("equiscor_equiscoreLive", $con);
// Write out our query.
$query = "SELECT * FROM tests";
// Execute it, or return the error message if there's a problem.
$result = mysql_query($query) or die(mysql_error());
$dropdown = "<select name='Test'>";
while($row = mysql_fetch_assoc($result)) {
$dropdown .= "\r\n<option value='{$row['Test']}'>{$row['Test']}</option>";
}
$dropdown .= "\r\n</select>";
$submit = '<input type="submit" name="submit" value="Submit" />';
echo '<form method="get" action="#">' . $dropdown . $submit . '</form>';
$result = mysql_query($test_query);
echo "<table border='1'>
<tr>
<th>Horse Number</th>
<th>Horse Name</th>
<th>Rider Name</th>
<th>E %</th>
<th>H %</th>
<th>C %</th>
<th>M %</th>
<th>B %</th>
<th>Total %</th>
<th>Errors</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Horse_Number'] . "</td>";
echo "<td>" . $row['Horse_Name'] . "</td>";
echo "<td>" . $row['Rider_Name'] . "</td>";
echo "<td>" . $row['E_Total_Percent'] . "%</td>";
echo "<td>" . $row['H_Total_Percent'] . "%</td>";
echo "<td>" . $row['C_Total_Percent'] . "%</td>";
echo "<td>" . $row['M_Total_Percent'] . "%</td>";
echo "<td>" . $row['B_Total_Percent'] . "%</td>";
echo "<td>" . $row['Total_Average'] . "%</td>";
echo "<td>" . $row['Errors'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?> Note if you intend to modify data in the database use POST not GET. Hope this is what you were after.
The code was not tested against a database.