我正在尝试在PHP中创建一个表单,然后将变量传递到下一页。我的问题是我的表单中的下拉元素根本没有传递它们的值。当我在下一页上执行print_r($ _ GET)以查看通过表单传递的值时,只显示类型为“text”或“radio”的输入。我不确定我做错了什么,因为我过去已经开始工作了。有人能帮我吗?我知道我从MySQL查询中提取的变量名称是正确的,就像ids一样。
//begin form
print "<form action = 'restaurant_confirm.php' method = 'GET'>";
print "Restaurant Name: <input type = 'text' size = 50 name = restaurant_name></br>";
// drop down for cuisine
print "Cuisine: <select>";
while ($row = mysql_fetch_array($cuisine_result) ){
print "<option name = 'cuisine' value = '".$row['cuisine_id']."'>". $row['cuisine_name']. "</option>";
}
print "</select></br>";
// drop down form restaurant type
print "Restaurant Type: <select>";
while ($row = mysql_fetch_array($type_result) ){
print "<option name = 'restaurant_type' value = '".$row['type_id']."'>";
print $row['restaurant_type'];
print "</option>";
}
print "</select></br>";
//Check boxes for price point
//table for alignment
print "Select one price point </br>";
print "<table>";
//header row
print "<tr>";
print "<td>Price Point</td>";
print "<td>Value</td>";
print "<td>Select</td>";
print "</tr>";
while ($row = mysql_fetch_array($price_result)) {
print "<tr>";
//prints the price point
print "<td>";
print $row['price_point'];
print "</td>";
//prints the value
print "<td>";
print $row['price_value'];
print "</td>";
print "<td>";
// radio button to choose
print "<input type = 'radio' name = 'price_selection' value = ".$row['price_id'].">";
print "</tr>";
}
print"</table></br>";
//Check boxes for gluten type
//table for alignment
print "Select one gluten type</br>";
print "<table>";
//header row
print "<tr>";
print "<td>Gluten Type</td>";
print "<td>Select</td>";
print "</tr>";
while ($row = mysql_fetch_array($gluten_result)) {
print "<tr>";
//prints the gluten type
print "<td>";
print $row['gluten_type'];
print "</td>";
print "<td>";
// radio button to choose
print "<input type = 'radio' name = 'gluten_selection' value = ".$row['gluten_type_id'].">";
print"</td>";
print "</tr>";
}
print "</table></br>";
//submit button
print "<input type = 'submit' value = 'Add'>";
print“”;
答案 0 :(得分:2)
您的select
没有名称,这是必需的。
将选择更改为<select name="whatever">
,您可以在下一页通过$_GET["whatever"]
获取。
答案 1 :(得分:0)
您的输入和选择字段未指定name
参数。 name
定义变量名称。
所以<input name="blah" />
将为$_GET['blah']