hi all,
I have created a select menu that displays results from a database.
The user selects an option from the menu and hits the Go button.
How do I display the users selection?(details in database)
Thanks.
My Select menu code::
echo '
<form id="FormName" action="view_result2.php" method="post" name="FormName">';
echo '<select name="menu" size="1">';
for ($i=0; $i<$num_results; $i++)
{
$row = mysql_fetch_array($result);
echo '<option value="'.($i+1).'">'.$row['name'].'</option>';
}
echo '</select>';
echo '<input type="submit" name="submit" value="Go">';
echo '</form>';
Here is my code to display users selection::
mysql_select_db('test') or die(mysql_error());
$query = "select name from answers where ".$menu." = name";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
for ($i=0; $i<$num_results; $i++)
{
$row = mysql_fetch_array($result);
echo 'Name selected: '.$row['name'];
}