I’m trying to pull a value from a drop down list. I’ve tried $_GET, $_POST and $_REQUEST without success. Please help if you can.
When the file loads it starts with the default content. It builds a drop down list from the database. The name and the id from the drop down list is “thedivision”.
[php] default:
print “
Select Your Division:   ”;
mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db($db_db) or die("Unable to select database");
$Divsql="SELECT DISTINCT Division FROM TeamDiv order by Division";
$result = mysql_query($Divsql);
$num = mysql_result($result,0);
$numrow = mysql_numrows($result);
echo "<select name='thedivision' id='thedivision'>";
echo "<option value='$num'>$num</option>";
while ($row = mysql_fetch_array($result)) {
if ($num != $row[Division]) {
$temp = $row[Division];
echo "<option value='$temp'>$temp</option>";
}
}
print "</select>";
?>
<br>
<form action="<?php print $update_page; ?>">
<input type="hidden" name="action" value="select_team">
<input type="submit" value="Next">
</form>
<?php
[/php]
The above appears to work correctly, but for some reason when I click on Next and load the content from case ‘select_team’, I can not retrieve the value from the drop down list (thedivision) that was in the section above. Below is the PHP in it’s natural order.
[php]<?php
$action = $_GET[‘action’];
switch($action) {
case 'select_team':
$thedivision = $_GET['thedivision'];
print "the division value from prior page: $thedivision";
break;
default:
print "<p><b>Select Your Division:   </b>";
mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db($db_db) or die("Unable to select database");
$Divsql="SELECT DISTINCT Division FROM TeamDiv order by Division";
$result = mysql_query($Divsql);
$num = mysql_result($result,0);
$numrow = mysql_numrows($result);
echo "<select name='thedivision' id='thedivision'>";
echo "<option value='$num'>$num</option>";
while ($row = mysql_fetch_array($result)) {
if ($num != $row[Division]) {
$temp = $row[Division];
echo "<option value='$temp'>$temp</option>";
}
}
print "</select>";
?>
<br>
<form action="<?php print $update_page; ?>">
<input type="hidden" name="action" value="select_team">
<input type="submit" value="Next">
</form>
<?php
}
?>[/php]