当前位置:编程学习 > php >>

php+ajax无刷新实现省、地、市易做图联动二

<?
$conn
=mysql_connect("localhost","root","2328725"
);
mysql_select_db("novel"
);
mysql_query("set names 'utf8'"
);
if(
$provincecode!=""&&$provincecode!=650000&&$provincecode!=710000&&$provincecode!=810000&&$provincecode!=820000&&$provincecode!=110000&&$provincecode!=120000&&$provincecode!=310000&&$provincecode!=500000
){
  
$sql="select * from city where provincecode=$provincecode"
;
  
$result=mysql_query($sql
);
  echo 
"<select onchange='queryArea(this.options[this.selectedIndex].value)'>\n"
;
  echo 
"<option value='-1' selected>请选择城市</option>\n"
;
  while(
$row=mysql_fetch_row($result
)){
   echo 
"<option value='$row[1]'>$row[2]</option>\n"
;
  }
  echo 
"</select>\n"
;
}

if(
$citycode!=""
){
  
$sql="select * from area where citycode=$citycode"
;
  
$result=mysql_query($sql
);
  echo 
"<select>\n"
;
  echo 
"<option value='-1' selected>请选择县</option>\n"
;
  while(
$row=mysql_fetch_row($result
)){
   echo 
"<option value='$row[1]'>$row[2]</option>\n"
;
  }
  echo 
"</select>\n"
;
}
?>

补充:Php教程,Php常用代码
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,