Hi I populate a drop down menu like this:
<select name="mySelect">
<?php $result= mysql_query('SELECT DISTINCT Year FROM MonthlySales'); ?>
<?php while($row= mysql_fetch_assoc($result)) { ?>
<option value="<?php echo htmlspecialchars($row['Year']);?>">
<?php echo htmlspecialchars($row['Year']); ?>
</option>
<?php } ?>
</select>
Then build a HTML table like this:
<?php
while( $row = mysql_fetch_row($results) ) {
echo "<tr>";
foreach($row as $cell) //Display all data in this row of user data...
echo "<td>$cell</td>";
echo "</tr>\n";
}
echo "</table>";
mysql_close($conn);
?>
My connection details look like so:
<?PHP
$conn = mysql_connect('localhost', 'root', 'root');
@mysql_select_db('localDB');
$query="SELECT * FROM MonthlySales";
$results = mysql_query ( $query, $conn);
echo "<table border='1'>";
echo "<tr><td>ID</td><td>ProductCode</td><td>Month</td><td>Year</td><td>SalesVolume</td></tr>";
?>
Now I want to only display the rows in the table with the year that the user has selected from my drop down box, I'm not sure how to link both the drop down box and the table together, can someone explain please.