php+省市区数据,php省市区数据库
PHP 省市区写在一起 怎样截取成单个的
有3种方法:
成都创新互联长期为上1000家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为绵阳企业提供专业的成都网站设计、网站制作,绵阳网站改版等技术服务。拥有十多年丰富建站经验和众多成功案例,为您定制开发。
1、手工一行一行的写成php代码
2、使用程序分析图一的数据,写入到数据库里,然后动态查询
3、使用程序分析图一的数据,写入到数据库里,动态生成图二的代码
php怎么写出全国的城市地区?
require 'city.php';
// 连接数据库(PDO)
$pdo=new PDO('mysql:host=localhost;dbname=city','root','root');
$pdo-exec('set names utf8');
$pdo-setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE,PDO::FETCH_ASSOC);
// 实例化城市类
$c=new city();
$result=$c-mycity();
$city_id = 0;
foreach ($result as $k=$value) {
if(count($value) == count($value,1)){
$sql="insert into city_province (province) value ('{$value['province_name']}')";
$smt=$pdo-prepare($sql);
$smt-execute();
}else{
$sql11="insert into city_province (province) value ('{$value['province_name']}')";
$smt11=$pdo-prepare($sql11);
$smt11-execute();
foreach ($value['city'] as $v=$value1) {
$sql2="insert into city_name (name,province_id) values ('{$value1['city_name']}','{$k}')";
$smt2=$pdo-prepare($sql2);
$smt2-execute();
$city_id += 1;
echo $city_id.'br';
if(!empty($value1['area'])){
foreach ($value1['area'] as $valu1e2) {
$sql3="insert into city_area (area,city_id) values ('{$valu1e2}','{$city_id}')";
$smt3=$pdo-prepare($sql3);
$smt3-execute();
}
}
}
}
}
城市类太大了,发不了。
我是把省、市、地区分别存在三个数据表中(我是新手,刚自己写的)
php怎么实现输出全国的省市区?
?php return array (
1 =
array (
'province_name' = '北京市',
'city' =
array (
1 =
array (
'city_name' = '市辖区',
'area' =
array (
1 = '东城区',
2 = '西城区',
3 = '崇文区',
4 = '宣武区',
5 = '朝阳区',
6 = '丰台区',
7 = '石景山区',
8 = '海淀区',
9 = '门头沟区',
10 = '房山区',
11 = '通州区',
12 = '顺义区',
13 = '昌平区',
14 = '大兴区',
15 = '怀柔区',
16 = '平谷区',
),
),
2 =
array (
'city_name' = '北京周边',
'area' =
array (
1 = '密云县',
2 = '延庆县',
),
),
),
),
2 =
array (
'province_name' = '天津市',
'city' =
array (
1 =
array (
'city_name' = '市辖区',
'area' =
array (
1 = '和平区',
2 = '河东区',
3 = '河西区',
4 = '南开区',
5 = '河北区',
6 = '红桥区',
7 = '塘沽区',
8 = '汉沽区',
9 = '大港区',
10 = '东丽区',
11 = '西青区',
12 = '津南区',
13 = '北辰区',
14 = '武清区',
15 = '宝坻区',
),
),
2 =
array (
'city_name' = '天津周边',
'area' =
array (
1 = '宁河县',
2 = '静海县',
3 = '蓟 县',
),
),
),
),
3 =
array (
'province_name' = '河北省',
'city' =
array (
1 =
array (
'city_name' = '石家庄市',
'area' =
array (
1 = '长安区',
2 = '桥东区',
3 = '桥西区',
4 = '新华区',
5 = '井陉矿区',
6 = '裕华区',
7 = '井陉县',
8 = '正定县',
9 = '栾城县',
10 = '行唐县',
11 = '灵寿县',
12 = '高邑县',
13 = '深泽县',
14 = '赞皇县',
15 = '无极县',
16 = '平山县',
17 = '元氏县',
18 = '赵 县',
19 = '辛集市',
20 = '藁城市',
21 = '晋州市',
22 = '新乐市',
23 = '鹿泉市',
),
),
2 =
array (
'city_name' = '唐山市',
'area' =
array (
1 = '路南区',
2 = '路北区',
3 = '古冶区',
4 = '开平区',
5 = '丰南区',
6 = '丰润区',
7 = '滦 县',
8 = '滦南县',
9 = '乐亭县',
10 = '迁西县',
11 = '玉田县',
12 = '唐海县',
13 = '遵化市',
14 = '迁安市',
),
),
3 =
array (
'city_name' = '秦皇岛市',
'area' =
array (
1 = '海港区',
2 = '山海关区',
3 = '北戴河区',
4 = '青龙满族自治县',
5 = '昌黎县',
6 = '抚宁县',
7 = '卢龙县',
),
),
4 =
array (
'city_name' = '邯郸市',
'area' =
array (
1 = '邯山区',
2 = '丛台区',
3 = '复兴区',
4 = '峰峰矿区',
5 = '邯郸县',
6 = '临漳县',
7 = '成安县',
8 = '大名县',
9 = '涉 县',
10 = '磁 县',
11 = '肥乡县',
12 = '永年县',
13 = '邱 县',
14 = '鸡泽县',
15 = '广平县',
16 = '馆陶县',
17 = '魏 县',
18 = '曲周县',
19 = '武安市',
),
),
5 =
array (
'city_name' = '邢台市',
'area' =
array (
1 = '桥东区',
2 = '桥西区',
3 = '邢台县',
4 = '临城县',
网页标题:php+省市区数据,php省市区数据库
URL地址:http://ybzwz.com/article/dsegeid.html