thinkphp 三个表做三级联动 求实例!
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏10(财富值+成长值)
1个回答
展开全部
<?php
header ( 'Content-type:text/html;charset=UTF-8' );
include_once ('connect.php');
switch ($_REQUEST ['category']) {
case 'province' :
$str = "<option value='0'>请选择省份</option>";
$sql = "select * from province";
$result = mysql_query ( $sql ) or die ( mysql_error );
if (mysql_num_rows ( $result ) > 0) {
while ( $row = mysql_fetch_array ( $result ) ) {
$str .= "<option value='" . $row ['id'] . "'>" . $row ['name'] . "</option>";
}
}
echo $str;
mysql_free_result ( $result );
break;
case 'city' :
$str = "<option value='0'>请选择城市</option>";
if ($_REQUEST ['province'] != "") {
$sql = "select * from city where province_id='" . $_REQUEST ['province'] . "'";
$result = mysql_query ( $sql ) or die ( mysql_error () );
if (mysql_num_rows ( $result ) > 0) {
while ( $row = mysql_fetch_array ( $result ) ) {
$str .= "<option value='" . $row ['id'] . "'>" . $row ['city_name'] . "</option>";
}
}
mysql_free_result ( $result );
}
echo $str;
break;
}
header ( 'Content-type:text/html;charset=UTF-8' );
include_once ('connect.php');
switch ($_REQUEST ['category']) {
case 'province' :
$str = "<option value='0'>请选择省份</option>";
$sql = "select * from province";
$result = mysql_query ( $sql ) or die ( mysql_error );
if (mysql_num_rows ( $result ) > 0) {
while ( $row = mysql_fetch_array ( $result ) ) {
$str .= "<option value='" . $row ['id'] . "'>" . $row ['name'] . "</option>";
}
}
echo $str;
mysql_free_result ( $result );
break;
case 'city' :
$str = "<option value='0'>请选择城市</option>";
if ($_REQUEST ['province'] != "") {
$sql = "select * from city where province_id='" . $_REQUEST ['province'] . "'";
$result = mysql_query ( $sql ) or die ( mysql_error () );
if (mysql_num_rows ( $result ) > 0) {
while ( $row = mysql_fetch_array ( $result ) ) {
$str .= "<option value='" . $row ['id'] . "'>" . $row ['city_name'] . "</option>";
}
}
mysql_free_result ( $result );
}
echo $str;
break;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询