我想要從PHP變量「list_cust_name」中選定的項目,通過在該WHERE子句中傳遞該PHP變量,通過該SQL查詢在另一個下拉列表「list_cust_city」中獲取值。這裏是我的代碼..請幫助我..如何獲得所選的下拉項目在php變量
<td width="228">
<label style="color:#000">Name </label>
<?php
$query_name = "SELECT DISTINCT cust_name FROM customer_db ORDER BY cust_name"; //Write a query
$data_name = mysql_query($query_name); //Execute the query
?>
<select id="list_cust_name" name="list_cust_name">
<?php
while($fetch_options_name = mysql_fetch_assoc($data_name)) { //Loop all the options retrieved from the query
?>
<option value="<?php echo $fetch_options_name['cust_name']; ?>"><?php echo $fetch_options_name['cust_name']; ?></option>
<?php
}
?>
</select>
</td>
<td width="250">
<label style="color:#000">City </label>
<?php
$query_city = "SELECT DISTINCT cust_city FROM customer_db ORDER BY cust_city"; //Write a query
$data_city = mysql_query($query_city); //Execute the query
?>
<select id="list_cust_city" name="list_cust_city">
<?php
while($fetch_options_city = mysql_fetch_assoc($data_city)) { //Loop all the options retrieved from the query
?>
<option value="<?php echo $fetch_options_city['cust_city']; ?>"><?php echo $fetch_options_city['cust_city']; ?></option>
<?php
}
?>
</select>
</td>
這裏你需要ajax。 – Jokey
無法得到您的實際問題... –
你想在這裏刷新頁面?或者@Jokey建議你在這裏需要ajax來達到這個效果 –