"http://www.w3.org/TR/xhtml1/DTD/xhtml1-t" />
搜档网
当前位置:搜档网 › ajax+php 级联列表

ajax+php 级联列表

主页面 jilian.php

/*
* Created on 2011-9-28
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
include_once("fun.php");
?>
"https://www.sodocs.net/doc/8212318478.html,/TR/xhtml1/DTD/xhtml1-transitional.dtd">











国家

省份

城市

县城

城镇







处理页面 province.php


/*
* Created on 2011-9-28
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
include_once(

"fun.php");
$cid=$_POST["id"];
//$cid = 1;
$sql = "select * from Provinces where cid='".$cid."'";
$res = mysql_query($sql);
$arr8 = array();
while($r = mysql_fetch_array($res)){
$arr8[] = array($r["pid"],$r["province"]);
}
//print_r($arr8);
$str = "";
$str .= "";
for($i=0;$i$str .="";
}


echo $str;

?>


city.php

/*
* Created on 2011-9-28
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
include_once("fun.php");
$pid=$_POST["id"];
//$cid = 1;
$sql = "select * from City where pid='".$pid."'";
$res = mysql_query($sql);
$arr8 = array();
while($r = mysql_fetch_array($res)){
$arr8[] = array($r["cid"],$r["city"]);
}
//print_r($arr8);
$str = "";
$str .= "";
for($i=0;$i$str .="";
}


echo $str;

?>

county.php

/*
* Created on 2011-9-28
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
include_once("fun.php");
$cid=$_POST["id"];
//$cid = 1;
$sql = "select * from County where cid='".$cid."'";
$res = mysql_query($sql);
$arr8 = array();
while($r = mysql_fetch_array($res)){
$arr8[] = array($r["xid"],$r["county"]);
}
//print_r($arr8);
$str = "";
$str .= "";
for($i=0;$i$str .="";
}


echo $str;

?>

town.php

/*
* Created on 2011-9-28
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
include_once("fun.php");
$xid=$_POST["id"];
//$cid = 1;
$sql = "select * from Town where xid='".$xid."'";
$res = mysql_query($sql);
$arr8 = array();
while($r = mysql_fetch_array($res)){
$arr8[] = array($r["tid"],$r["town"]);
}
//print_r($arr8);
$str = "";
$str .= "";
for($i=0;$i$str .="";
}


echo $str;

?>

数据库连接fun.php
/*
* Created on 2011-9-28
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
include_once("adodb/adodb.inc.php");
mysql_connect("localhost", "root", "frotune123") or die("数据库连接失败!");
mysql_select_db("COUNTRY");
mysql_query("set names 'utf8' ");
?>





数据库:数据库名COUNTRY


/*
Navicat MySQL Data Transfer

Source Server : 192.168.110.12_3306
Source Server Version : 50152
Source Host : 192.168.1

10.12:3306
Source Database : COUNTRY

Target Server Type : MYSQL
Target Server Version : 50152
File Encoding : 65001

Date: 2011-09-29 15:38:27
*/

SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `City`
-- ----------------------------
DROP TABLE IF EXISTS `City`;
CREATE TABLE `City` (
`cid` int(2) NOT NULL AUTO_INCREMENT,
`pid` int(2) NOT NULL,
`city` varchar(20) NOT NULL,
PRIMARY KEY (`cid`)
) ENGINE=MyISAM AUTO_INCREMENT=24 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of City
-- ----------------------------
INSERT INTO City VALUES ('1', '1', '石家庄');
INSERT INTO City VALUES ('2', '1', '衡水');
INSERT INTO City VALUES ('3', '1', '保定');
INSERT INTO City VALUES ('4', '2', '郑州');
INSERT INTO City VALUES ('5', '2', '洛阳');
INSERT INTO City VALUES ('6', '2', '驻马店');
INSERT INTO City VALUES ('7', '3', '苏州');
INSERT INTO City VALUES ('8', '3', '宿迁');
INSERT INTO City VALUES ('9', '3', '南京');
INSERT INTO City VALUES ('10', '4', '长沙');
INSERT INTO City VALUES ('11', '4', '衡阳');
INSERT INTO City VALUES ('12', '4', '张家界');
INSERT INTO City VALUES ('13', '5', '亚拉巴马州');
INSERT INTO City VALUES ('14', '5', '阿拉斯加州');
INSERT INTO City VALUES ('15', '5', '亚利桑那州');
INSERT INTO City VALUES ('16', '6', '阿肯色州');
INSERT INTO City VALUES ('17', '6', '加利福尼亚州');
INSERT INTO City VALUES ('18', '6', '科罗拉多州');
INSERT INTO City VALUES ('19', '7', '特拉华州');
INSERT INTO City VALUES ('20', '7', '佛罗里达州');
INSERT INTO City VALUES ('21', '8', '温哥华');
INSERT INTO City VALUES ('22', '9', '埃德蒙顿市');
INSERT INTO City VALUES ('23', '10', '瑞吉娜');

-- ----------------------------
-- Table structure for `Country`
-- ----------------------------
DROP TABLE IF EXISTS `Country`;
CREATE TABLE `Country` (
`cid` int(2) NOT NULL AUTO_INCREMENT,
`country` varchar(20) DEFAULT NULL,
PRIMARY KEY (`cid`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of Country
-- ----------------------------
INSERT INTO Country VALUES ('1', '中国');
INSERT INTO Country VALUES ('2', '美国');
INSERT INTO Country VALUES ('3', '加拿大');

-- ----------------------------
-- Table structure for `County`
-- ----------------------------
DROP TABLE IF EXISTS `County`;
CREATE TABLE `County` (
`xid` int(2) NOT NULL AUTO_INCREMENT,
`cid` int(2) NOT NULL,
`county` varchar(20) NOT NULL,
PRIMARY KEY (`xid`)
) ENGINE=MyISAM AUTO_INCREMENT=24 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of County
-- ----------------------------
INSERT INTO County VALUES ('1', '1', '正定县');
INSERT INTO County VALUES ('2', '2', '景县');
INSERT INTO County VALUES ('3', '3', '保定的县');
INSERT INTO County VALUES ('4', '4', '郑州的县');
INS

ERT INTO County VALUES ('5', '5', '洛阳的县');
INSERT INTO County VALUES ('6', '6', '驻马店的县');
INSERT INTO County VALUES ('7', '7', '昆山');
INSERT INTO County VALUES ('8', '8', '宿迁的县');
INSERT INTO County VALUES ('9', '9', '南京的县');
INSERT INTO County VALUES ('10', '10', '长沙的县');
INSERT INTO County VALUES ('11', '11', '衡阳的县');
INSERT INTO County VALUES ('12', '12', '张家界的县');
INSERT INTO County VALUES ('13', '13', '亚拉巴马');
INSERT INTO County VALUES ('14', '14', '阿拉斯加');
INSERT INTO County VALUES ('15', '15', '亚利桑那');
INSERT INTO County VALUES ('16', '16', '阿肯色');
INSERT INTO County VALUES ('17', '17', '加利福尼亚');
INSERT INTO County VALUES ('18', '18', '科罗拉多');
INSERT INTO County VALUES ('19', '19', '特拉华');
INSERT INTO County VALUES ('20', '20', '佛罗里达的县');
INSERT INTO County VALUES ('21', '21', '温哥华的县');
INSERT INTO County VALUES ('22', '22', '埃德蒙顿');
INSERT INTO County VALUES ('23', '23', '瑞吉娜的县');

-- ----------------------------
-- Table structure for `Provinces`
-- ----------------------------
DROP TABLE IF EXISTS `Provinces`;
CREATE TABLE `Provinces` (
`pid` int(2) NOT NULL AUTO_INCREMENT,
`cid` int(2) NOT NULL,
`province` varchar(20) NOT NULL,
PRIMARY KEY (`pid`)
) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of Provinces
-- ----------------------------
INSERT INTO Provinces VALUES ('1', '1', '河北');
INSERT INTO Provinces VALUES ('2', '1', '河南');
INSERT INTO Provinces VALUES ('3', '1', '江苏');
INSERT INTO Provinces VALUES ('4', '1', '湖南');
INSERT INTO Provinces VALUES ('5', '2', '新英格兰地区');
INSERT INTO Provinces VALUES ('6', '2', '中央地区');
INSERT INTO Provinces VALUES ('7', '2', '中大西洋地区');
INSERT INTO Provinces VALUES ('8', '3', '不列颠哥伦比亚省');
INSERT INTO Provinces VALUES ('9', '3', '阿尔伯塔省');
INSERT INTO Provinces VALUES ('10', '3', '萨斯喀彻温省');

-- ----------------------------
-- Table structure for `Town`
-- ----------------------------
DROP TABLE IF EXISTS `Town`;
CREATE TABLE `Town` (
`tid` int(2) NOT NULL AUTO_INCREMENT,
`xid` int(2) NOT NULL,
`town` varchar(20) NOT NULL,
PRIMARY KEY (`tid`)
) ENGINE=MyISAM AUTO_INCREMENT=26 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of Town
-- ----------------------------
INSERT INTO Town VALUES ('1', '1', '正定的镇');
INSERT INTO Town VALUES ('2', '2', '杜桥');
INSERT INTO Town VALUES ('3', '2', '龙华');
INSERT INTO Town VALUES ('4', '3', '保定的镇');
INSERT INTO Town VALUES ('5', '4', '郑州的镇');
INSERT INTO Town VALUES ('6', '5', '洛阳镇');
INSERT INTO Town VALUES ('7', '6', '驻马镇');
INSERT INTO Town VALUES ('8', '7', '花桥');
INSERT INTO Town VALUES ('9', '7', '陆家');
INSERT INTO Town VALUE

S ('10', '8', '宿迁的镇');
INSERT INTO Town VALUES ('11', '9', '南京的镇');
INSERT INTO Town VALUES ('12', '10', '长沙的镇');
INSERT INTO Town VALUES ('13', '11', '衡阳镇');
INSERT INTO Town VALUES ('14', '12', '张家界镇');
INSERT INTO Town VALUES ('15', '13', '亚拉巴马镇');
INSERT INTO Town VALUES ('16', '14', '阿拉斯加镇');
INSERT INTO Town VALUES ('17', '15', '亚利桑纳镇');
INSERT INTO Town VALUES ('18', '16', '阿肯色镇');
INSERT INTO Town VALUES ('19', '17', '加利福尼亚镇');
INSERT INTO Town VALUES ('20', '18', '科罗拉多镇');
INSERT INTO Town VALUES ('21', '19', '特拉华镇');
INSERT INTO Town VALUES ('22', '20', '佛罗里达镇');
INSERT INTO Town VALUES ('23', '21', '温哥华镇');
INSERT INTO Town VALUES ('24', '22', '埃德蒙顿镇');
INSERT INTO Town VALUES ('25', '23', '瑞吉娜镇');


相关主题