在PHP中检索组合框的值 [英] retrieving the value of a combobox in PHP
本文介绍了在PHP中检索组合框的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
美好的一天
我正面临着我的代码挑战。我想要做的是有两个组合框,一个叫省,另一个城市,当用户选择一个省时,它应该只显示城市组合框中该省的城市。我怎么能用PHP实现这一点?
Good Day all
i am facing a challenge with my code. what i am trying to do is have two comboboxes one called province and the other one city, when the user selects a province it should only display the cities in that province in the city combobox. how can i achive this using PHP ?
function getCity($provinceId)
{
$sql ="SELECT `cityid`,`cityname` FROM `tblcity` inner join `tblprovince` ON `tblcity`.`pid`='$provinceId' order by `cityid` asc";
$query = mysql_query($sql) or die ("Could not access DB: " . mysql_error());
$row = mysql_fetch_assoc($query);
while($row)
{
$id = $row['cityid'];
$name = $row['cityname'];
echo
"
<option value ='$id'>".$name."</option>
";
$row = mysql_fetch_assoc($query);
}
}
这是我的功能现在看起来我现在无法检索到的值省组合框。任何帮助将不胜感激。
提前致谢
this is what my fuction looks like now i am unable to retrieve the values of the province combo box. any help will be appreciated.
Thanks in advance
推荐答案
provinceId)
{
provinceId) {
sql = SELECT`castid`,`cityname` FROM`tblcity` inner join`tblprovince` ON`tblcity``pid` ='
sql ="SELECT `cityid`,`cityname` FROM `tblcity` inner join `tblprovince` ON `tblcity`.`pid`='
provinceId'由'cityid'命令ASC跨度>;
provinceId' order by `cityid` asc";
这篇关于在PHP中检索组合框的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文