onchange
事件添加到下拉列表HTML
<div>
<form method="post">
<tr>
<td>Select Branch</td>
<td>
<select name="Branch" onchange="this.form.submit()">
<option value="">Select Branch</option>
<?php
$query = "SELECT * FROM Branch";
$result = mysqli_query($link,$query);
foreach($result as $branch)
{
?>
<option value="<?php echo $branch["branch_id"]; ?>"><?php echo $branch["branch_name"]; ?></option>
<?php
}
?>
</select>
</td>
</tr>
</form>
</div>
PHP
<?php
$bid=$branch["branch_id"];
if(isset($_GET["Branch"]))
{
$_SESSION["location"]=$bid;
?>
<script type="text/javascript">
window.location="/fyp/user/shop.php";
</script>
<?php
}
?>
答案 0 :(得分:1)
您通过POST
发送表单,但请检查$_GET["Branch"]
。
选择其中一个。通过GET
=&gt;发送您的HTML中的method="GET"
,或POST
=&gt;检查$_POST["Branch"]
。