【发布时间】:2014-02-08 07:55:45
【问题描述】:
我想要从listbox 中选择的值并希望存储在 php 变量中,因为我想使用该变量以供进一步使用。请帮忙..
<form name="myform" method="post">
<?php
include('dbconnect.php');
db_connect();
$query = "SELECT * FROM test_customer"; //Write a query
$data = mysql_query($query); //Execute the query
?>
<select id="cust_name" name="mylist" onchange="selectedvalue()">
<?php
while($fetch_options = mysql_fetch_array($data)) { //Loop all the options retrieved from the query
?>
//Added Id for Options Element
<option id ="<?php echo $fetch_options['test_id']; ?>" value="<?php echo $fetch_options['cust_name']; ?>"><?php echo $fetch_options['cust_name']; ?></option><!--Echo out options-->
<?php
}
?>
</select>
</form>
【问题讨论】:
-
使用 $_POST 处理表单后,为什么不将其保存在 php 变量中?
标签: php listbox selectedvalue