来自动作值的php从下拉列表中获取

时间:2015-04-03 20:13:13

标签: php html forms drop-down-menu

我的目标是获得两个下拉值,然后将其传递给action,然后将其传递到$_POST到下一个.php页面。简而言之,我想使用action菜单选择drop-down php页面。

我在这里做错了,无论我从page下拉菜单中选择什么,它总是默认选择page1.php

<html>
<body>

<select name='page'>
<option value='page1.php'>page1</option>
<option value='page2.php'>page2</option>
</select>

<form name="page" method="post" action="<?php echo $_POST['page']; ?>">
<?php
// DB connection info:
include 'db_connection.php';

$sql = "SHOW tables";
$result = mysql_query($sql);

echo "<select name='param1'>";
while ($row = mysql_fetch_array($result)) {
    echo "<option value='" . $row['Tables_in_radius'] . "'>" . $row['Tables_in_radius'] . "</option>";
}
echo "</select>";

?>

<input type="submit" value="send">
</form>
<?php
if(isset($_POST['param1'])){
}
?>

</body>
</html>

1 个答案:

答案 0 :(得分:0)

1)将下拉放在表格内。

2)if(isset($ _ POST [&#39; param1&#39;]))&lt; - 什么是param1?  将其更改为:$ _POST [&#39; page&#39;]