Posted by barbarowa on 02/05/06 23:50
I've coded a script to populate a drop down menu from a database but I
can't seem to get the PHP script to pass the selected item. The
database only has two fields, ID and ITEM. I want the user to be able
to see all the choices and pick one. This choice would then be used
to update another database.
The drop down menu populates correctly. When I test for the variable
being passed, nothing is showing up. Here is the code:
<?php
include("connect.php");
if($_POST['testform']) {
print_r($HTTP_POST_VARS);
exit;
}
?>
<form name="testform" action="<?php echo $PHP_SELF; ?>" method="post">
<?php
$query = "SELECT * FROM mytable ORDER BY item";
$result = mysql_query($query) or die ("$text[cannotexecutequery]:
$query");
echo "<select name='id'>";
while($row=mysql_fetch_assoc($result))
{
echo "<option value=" . $row['id'].">".$row['item']."</option>";
}
echo "</select>";
echo "<input type='submit' value='Submit' name='testform'>
<input type='reset' value='Reset' name='reset'>
</form>";
?>
Navigation:
[Reply to this message]
|