Hi,
I'm creating a web page which links to a mysql database. I have managed to get all of the data to appear in a table and i have also been able to get the combobox to be populated based on a table in the database. The part which I am having trouble with is joining them together so when you select an option in the combobox, the data is filtered and displayed in the table.
My code is below
<?php header('Refresh: 30'); ?>
<?php
$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>";
echo $dropdown;
$result = mysql_query("SELECT * FROM scores");
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);
?>
Thanks in advance
Chris