ty532021 2016-12-10 18:35:36 1217次浏览 5条回复 8 3 0

写的不好,多多指正。以下是分享的内容
表结构

-- ----------------------------
-- Table structure for `tbl_area`
-- ----------------------------
DROP TABLE IF EXISTS `tbl_area`;
CREATE TABLE `tbl_area` (
  `id` int(12) NOT NULL AUTO_INCREMENT,
  `cityname` varchar(22) NOT NULL,
  `parentid` int(12) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=381 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of tbl_area
-- ----------------------------
INSERT INTO `tbl_area` VALUES ('1', '北京市', '0');
INSERT INTO `tbl_area` VALUES ('2', '天津市', '0');
INSERT INTO `tbl_area` VALUES ('3', '河北省', '0');
INSERT INTO `tbl_area` VALUES ('4', '山西省', '0');
INSERT INTO `tbl_area` VALUES ('5', '内蒙古自治区', '0');
INSERT INTO `tbl_area` VALUES ('6', '辽宁省', '0');
INSERT INTO `tbl_area` VALUES ('7', '吉林省', '0');
INSERT INTO `tbl_area` VALUES ('8', '黑龙江省', '0');
INSERT INTO `tbl_area` VALUES ('9', '上海市', '0');
INSERT INTO `tbl_area` VALUES ('10', '江苏省', '0');
INSERT INTO `tbl_area` VALUES ('11', '浙江省', '0');
INSERT INTO `tbl_area` VALUES ('12', '安徽省', '0');
INSERT INTO `tbl_area` VALUES ('13', '福建省', '0');
INSERT INTO `tbl_area` VALUES ('14', '江西省', '0');
INSERT INTO `tbl_area` VALUES ('15', '山东省', '0');
INSERT INTO `tbl_area` VALUES ('16', '河南省', '0');
INSERT INTO `tbl_area` VALUES ('17', '湖北省', '0');
INSERT INTO `tbl_area` VALUES ('18', '湖南省', '0');
INSERT INTO `tbl_area` VALUES ('19', '广东省', '0');
INSERT INTO `tbl_area` VALUES ('20', '广西壮族自治区', '0');
INSERT INTO `tbl_area` VALUES ('21', '海南省', '0');
INSERT INTO `tbl_area` VALUES ('22', '重庆市', '0');
INSERT INTO `tbl_area` VALUES ('23', '四川省', '0');
INSERT INTO `tbl_area` VALUES ('24', '贵州省', '0');
INSERT INTO `tbl_area` VALUES ('25', '云南省', '0');
INSERT INTO `tbl_area` VALUES ('26', '西藏自治区', '0');
INSERT INTO `tbl_area` VALUES ('27', '陕西省', '0');
INSERT INTO `tbl_area` VALUES ('28', '甘肃省', '0');
INSERT INTO `tbl_area` VALUES ('29', '青海省', '0');
INSERT INTO `tbl_area` VALUES ('30', '宁夏回族自治区', '0');
INSERT INTO `tbl_area` VALUES ('31', '新疆维吾尔自治区', '0');
INSERT INTO `tbl_area` VALUES ('32', '香港特别行政区', '0');
INSERT INTO `tbl_area` VALUES ('33', '澳门特别行政区', '0');
INSERT INTO `tbl_area` VALUES ('34', '台湾省', '0');
INSERT INTO `tbl_area` VALUES ('35', '北京', '1');
INSERT INTO `tbl_area` VALUES ('36', '天津市', '2');
INSERT INTO `tbl_area` VALUES ('37', '石家庄市', '3');
INSERT INTO `tbl_area` VALUES ('38', '唐山市', '3');
INSERT INTO `tbl_area` VALUES ('39', '秦皇岛市', '3');
INSERT INTO `tbl_area` VALUES ('40', '邯郸市', '3');
INSERT INTO `tbl_area` VALUES ('41', '邢台市', '3');
INSERT INTO `tbl_area` VALUES ('42', '保定市', '3');
INSERT INTO `tbl_area` VALUES ('43', '张家口市', '3');
INSERT INTO `tbl_area` VALUES ('44', '承德市', '3');
INSERT INTO `tbl_area` VALUES ('45', '沧州市', '3');
INSERT INTO `tbl_area` VALUES ('46', '廊坊市', '3');
INSERT INTO `tbl_area` VALUES ('47', '衡水市', '3');
INSERT INTO `tbl_area` VALUES ('48', '太原市', '4');
INSERT INTO `tbl_area` VALUES ('49', '大同市', '4');
INSERT INTO `tbl_area` VALUES ('50', '阳泉市', '4');
INSERT INTO `tbl_area` VALUES ('51', '长治市', '4');
INSERT INTO `tbl_area` VALUES ('52', '晋城市', '4');
INSERT INTO `tbl_area` VALUES ('53', '朔州市', '4');
INSERT INTO `tbl_area` VALUES ('54', '晋中市', '4');
INSERT INTO `tbl_area` VALUES ('55', '运城市', '4');
INSERT INTO `tbl_area` VALUES ('56', '忻州市', '4');
INSERT INTO `tbl_area` VALUES ('57', '临汾市', '4');
INSERT INTO `tbl_area` VALUES ('58', '吕梁市', '4');
INSERT INTO `tbl_area` VALUES ('59', '呼和浩特市', '5');
INSERT INTO `tbl_area` VALUES ('60', '包头市', '5');
INSERT INTO `tbl_area` VALUES ('61', '乌海市', '5');
INSERT INTO `tbl_area` VALUES ('62', '赤峰市', '5');
INSERT INTO `tbl_area` VALUES ('63', '通辽市', '5');
INSERT INTO `tbl_area` VALUES ('64', '鄂尔多斯市', '5');
INSERT INTO `tbl_area` VALUES ('65', '呼伦贝尔市', '5');
INSERT INTO `tbl_area` VALUES ('66', '巴彦淖尔市', '5');
INSERT INTO `tbl_area` VALUES ('67', '乌兰察布市', '5');
INSERT INTO `tbl_area` VALUES ('68', '兴安盟', '5');
INSERT INTO `tbl_area` VALUES ('69', '锡林郭勒盟', '5');
INSERT INTO `tbl_area` VALUES ('70', '阿拉善盟', '5');
INSERT INTO `tbl_area` VALUES ('71', '沈阳市', '6');
INSERT INTO `tbl_area` VALUES ('72', '大连市', '6');
INSERT INTO `tbl_area` VALUES ('73', '鞍山市', '6');
INSERT INTO `tbl_area` VALUES ('74', '抚顺市', '6');
INSERT INTO `tbl_area` VALUES ('75', '本溪市', '6');
INSERT INTO `tbl_area` VALUES ('76', '丹东市', '6');
INSERT INTO `tbl_area` VALUES ('77', '锦州市', '6');
INSERT INTO `tbl_area` VALUES ('78', '营口市', '6');
INSERT INTO `tbl_area` VALUES ('79', '阜新市', '6');
INSERT INTO `tbl_area` VALUES ('80', '辽阳市', '6');
INSERT INTO `tbl_area` VALUES ('81', '盘锦市', '6');
INSERT INTO `tbl_area` VALUES ('82', '铁岭市', '6');
INSERT INTO `tbl_area` VALUES ('83', '朝阳市', '6');
INSERT INTO `tbl_area` VALUES ('84', '葫芦岛市', '6');
INSERT INTO `tbl_area` VALUES ('85', '长春市', '7');
INSERT INTO `tbl_area` VALUES ('86', '吉林市', '7');
INSERT INTO `tbl_area` VALUES ('87', '四平市', '7');
INSERT INTO `tbl_area` VALUES ('88', '辽源市', '7');
INSERT INTO `tbl_area` VALUES ('89', '通化市', '7');
INSERT INTO `tbl_area` VALUES ('90', '白山市', '7');
INSERT INTO `tbl_area` VALUES ('91', '松原市', '7');
INSERT INTO `tbl_area` VALUES ('92', '白城市', '7');
INSERT INTO `tbl_area` VALUES ('93', '延边朝鲜族自治州', '7');
INSERT INTO `tbl_area` VALUES ('94', '哈尔滨市', '8');
INSERT INTO `tbl_area` VALUES ('95', '齐齐哈尔市', '8');
INSERT INTO `tbl_area` VALUES ('96', '鸡西市', '8');
INSERT INTO `tbl_area` VALUES ('97', '鹤岗市', '8');
INSERT INTO `tbl_area` VALUES ('98', '双鸭山市', '8');
INSERT INTO `tbl_area` VALUES ('99', '大庆市', '8');
INSERT INTO `tbl_area` VALUES ('100', '伊春市', '8');
INSERT INTO `tbl_area` VALUES ('101', '佳木斯市', '8');
INSERT INTO `tbl_area` VALUES ('102', '七台河市', '8');
INSERT INTO `tbl_area` VALUES ('103', '牡丹江市', '8');
INSERT INTO `tbl_area` VALUES ('104', '黑河市', '8');
INSERT INTO `tbl_area` VALUES ('105', '绥化市', '8');
INSERT INTO `tbl_area` VALUES ('106', '大兴安岭地区', '8');
INSERT INTO `tbl_area` VALUES ('107', '上海市', '9');
INSERT INTO `tbl_area` VALUES ('108', '南京市', '10');
INSERT INTO `tbl_area` VALUES ('109', '无锡市', '10');
INSERT INTO `tbl_area` VALUES ('110', '徐州市', '10');
INSERT INTO `tbl_area` VALUES ('111', '常州市', '10');
INSERT INTO `tbl_area` VALUES ('112', '苏州市', '10');
INSERT INTO `tbl_area` VALUES ('113', '南通市', '10');
INSERT INTO `tbl_area` VALUES ('114', '连云港市', '10');
INSERT INTO `tbl_area` VALUES ('115', '淮安市', '10');
INSERT INTO `tbl_area` VALUES ('116', '盐城市', '10');
INSERT INTO `tbl_area` VALUES ('117', '扬州市', '10');
INSERT INTO `tbl_area` VALUES ('118', '镇江市', '10');
INSERT INTO `tbl_area` VALUES ('119', '泰州市', '10');
INSERT INTO `tbl_area` VALUES ('120', '宿迁市', '10');
INSERT INTO `tbl_area` VALUES ('121', '杭州市', '11');
INSERT INTO `tbl_area` VALUES ('122', '宁波市', '11');
INSERT INTO `tbl_area` VALUES ('123', '温州市', '11');
INSERT INTO `tbl_area` VALUES ('124', '嘉兴市', '11');
INSERT INTO `tbl_area` VALUES ('125', '湖州市', '11');
INSERT INTO `tbl_area` VALUES ('126', '绍兴市', '11');
INSERT INTO `tbl_area` VALUES ('127', '金华市', '11');
INSERT INTO `tbl_area` VALUES ('128', '衢州市', '11');
INSERT INTO `tbl_area` VALUES ('129', '舟山市', '11');
INSERT INTO `tbl_area` VALUES ('130', '台州市', '11');
INSERT INTO `tbl_area` VALUES ('131', '丽水市', '11');
INSERT INTO `tbl_area` VALUES ('132', '合肥市', '12');
INSERT INTO `tbl_area` VALUES ('133', '芜湖市', '12');
INSERT INTO `tbl_area` VALUES ('134', '蚌埠市', '12');
INSERT INTO `tbl_area` VALUES ('135', '淮南市', '12');
INSERT INTO `tbl_area` VALUES ('136', '马鞍山市', '12');
INSERT INTO `tbl_area` VALUES ('137', '淮北市', '12');
INSERT INTO `tbl_area` VALUES ('138', '铜陵市', '12');
INSERT INTO `tbl_area` VALUES ('139', '安庆市', '12');
INSERT INTO `tbl_area` VALUES ('140', '黄山市', '12');
INSERT INTO `tbl_area` VALUES ('141', '滁州市', '12');
INSERT INTO `tbl_area` VALUES ('142', '阜阳市', '12');
INSERT INTO `tbl_area` VALUES ('143', '宿州市', '12');
INSERT INTO `tbl_area` VALUES ('144', '巢湖市', '12');
INSERT INTO `tbl_area` VALUES ('145', '六安市', '12');
INSERT INTO `tbl_area` VALUES ('146', '亳州市', '12');
INSERT INTO `tbl_area` VALUES ('147', '池州市', '12');
INSERT INTO `tbl_area` VALUES ('148', '宣城市', '12');
INSERT INTO `tbl_area` VALUES ('149', '福州市', '13');
INSERT INTO `tbl_area` VALUES ('150', '厦门市', '13');
INSERT INTO `tbl_area` VALUES ('151', '莆田市', '13');
INSERT INTO `tbl_area` VALUES ('152', '三明市', '13');
INSERT INTO `tbl_area` VALUES ('153', '泉州市', '13');
INSERT INTO `tbl_area` VALUES ('154', '漳州市', '13');
INSERT INTO `tbl_area` VALUES ('155', '南平市', '13');
INSERT INTO `tbl_area` VALUES ('156', '龙岩市', '13');
INSERT INTO `tbl_area` VALUES ('157', '宁德市', '13');
INSERT INTO `tbl_area` VALUES ('158', '南昌市', '14');
INSERT INTO `tbl_area` VALUES ('159', '景德镇市', '14');
INSERT INTO `tbl_area` VALUES ('160', '萍乡市', '14');
INSERT INTO `tbl_area` VALUES ('161', '九江市', '14');
INSERT INTO `tbl_area` VALUES ('162', '新余市', '14');
INSERT INTO `tbl_area` VALUES ('163', '鹰潭市', '14');
INSERT INTO `tbl_area` VALUES ('164', '赣州市', '14');
INSERT INTO `tbl_area` VALUES ('165', '吉安市', '14');
INSERT INTO `tbl_area` VALUES ('166', '宜春市', '14');
INSERT INTO `tbl_area` VALUES ('167', '抚州市', '14');
INSERT INTO `tbl_area` VALUES ('168', '上饶市', '14');
INSERT INTO `tbl_area` VALUES ('169', '济南市', '15');
INSERT INTO `tbl_area` VALUES ('170', '青岛市', '15');
INSERT INTO `tbl_area` VALUES ('171', '淄博市', '15');
INSERT INTO `tbl_area` VALUES ('172', '枣庄市', '15');
INSERT INTO `tbl_area` VALUES ('173', '东营市', '15');
INSERT INTO `tbl_area` VALUES ('174', '烟台市', '15');
INSERT INTO `tbl_area` VALUES ('175', '潍坊市', '15');
INSERT INTO `tbl_area` VALUES ('176', '济宁市', '15');
INSERT INTO `tbl_area` VALUES ('177', '泰安市', '15');
INSERT INTO `tbl_area` VALUES ('178', '威海市', '15');
INSERT INTO `tbl_area` VALUES ('179', '日照市', '15');
INSERT INTO `tbl_area` VALUES ('180', '莱芜市', '15');
INSERT INTO `tbl_area` VALUES ('181', '临沂市', '15');
INSERT INTO `tbl_area` VALUES ('182', '德州市', '15');
INSERT INTO `tbl_area` VALUES ('183', '聊城市', '15');
INSERT INTO `tbl_area` VALUES ('184', '滨州市', '15');
INSERT INTO `tbl_area` VALUES ('185', '荷泽市', '15');
INSERT INTO `tbl_area` VALUES ('186', '郑州市', '16');
INSERT INTO `tbl_area` VALUES ('187', '开封市', '16');
INSERT INTO `tbl_area` VALUES ('188', '洛阳市', '16');
INSERT INTO `tbl_area` VALUES ('189', '平顶山市', '16');
INSERT INTO `tbl_area` VALUES ('190', '安阳市', '16');
INSERT INTO `tbl_area` VALUES ('191', '鹤壁市', '16');
INSERT INTO `tbl_area` VALUES ('192', '新乡市', '16');
INSERT INTO `tbl_area` VALUES ('193', '焦作市', '16');
INSERT INTO `tbl_area` VALUES ('194', '濮阳市', '16');
INSERT INTO `tbl_area` VALUES ('195', '许昌市', '16');
INSERT INTO `tbl_area` VALUES ('196', '漯河市', '16');
INSERT INTO `tbl_area` VALUES ('197', '三门峡市', '16');
INSERT INTO `tbl_area` VALUES ('198', '南阳市', '16');
INSERT INTO `tbl_area` VALUES ('199', '商丘市', '16');
INSERT INTO `tbl_area` VALUES ('200', '信阳市', '16');
INSERT INTO `tbl_area` VALUES ('201', '周口市', '16');
INSERT INTO `tbl_area` VALUES ('202', '驻马店市', '16');
INSERT INTO `tbl_area` VALUES ('203', '武汉市', '17');
INSERT INTO `tbl_area` VALUES ('204', '黄石市', '17');
INSERT INTO `tbl_area` VALUES ('205', '十堰市', '17');
INSERT INTO `tbl_area` VALUES ('206', '宜昌市', '17');
INSERT INTO `tbl_area` VALUES ('207', '襄樊市', '17');
INSERT INTO `tbl_area` VALUES ('208', '鄂州市', '17');
INSERT INTO `tbl_area` VALUES ('209', '荆门市', '17');
INSERT INTO `tbl_area` VALUES ('210', '孝感市', '17');
INSERT INTO `tbl_area` VALUES ('211', '荆州市', '17');
INSERT INTO `tbl_area` VALUES ('212', '黄冈市', '17');
INSERT INTO `tbl_area` VALUES ('213', '咸宁市', '17');
INSERT INTO `tbl_area` VALUES ('214', '随州市', '17');
INSERT INTO `tbl_area` VALUES ('215', '恩施土家族苗族自治州', '17');
INSERT INTO `tbl_area` VALUES ('216', '神农架', '17');
INSERT INTO `tbl_area` VALUES ('217', '长沙市', '18');
INSERT INTO `tbl_area` VALUES ('218', '株洲市', '18');
INSERT INTO `tbl_area` VALUES ('219', '湘潭市', '18');
INSERT INTO `tbl_area` VALUES ('220', '衡阳市', '18');
INSERT INTO `tbl_area` VALUES ('221', '邵阳市', '18');
INSERT INTO `tbl_area` VALUES ('222', '岳阳市', '18');
INSERT INTO `tbl_area` VALUES ('223', '常德市', '18');
INSERT INTO `tbl_area` VALUES ('224', '张家界市', '18');
INSERT INTO `tbl_area` VALUES ('225', '益阳市', '18');
INSERT INTO `tbl_area` VALUES ('226', '郴州市', '18');
INSERT INTO `tbl_area` VALUES ('227', '永州市', '18');
INSERT INTO `tbl_area` VALUES ('228', '怀化市', '18');
INSERT INTO `tbl_area` VALUES ('229', '娄底市', '18');
INSERT INTO `tbl_area` VALUES ('230', '湘西土家族苗族自治州', '18');
INSERT INTO `tbl_area` VALUES ('231', '广州市', '19');
INSERT INTO `tbl_area` VALUES ('232', '韶关市', '19');
INSERT INTO `tbl_area` VALUES ('233', '深圳市', '19');
INSERT INTO `tbl_area` VALUES ('234', '珠海市', '19');
INSERT INTO `tbl_area` VALUES ('235', '汕头市', '19');
INSERT INTO `tbl_area` VALUES ('236', '佛山市', '19');
INSERT INTO `tbl_area` VALUES ('237', '江门市', '19');
INSERT INTO `tbl_area` VALUES ('238', '湛江市', '19');
INSERT INTO `tbl_area` VALUES ('239', '茂名市', '19');
INSERT INTO `tbl_area` VALUES ('240', '肇庆市', '19');
INSERT INTO `tbl_area` VALUES ('241', '惠州市', '19');
INSERT INTO `tbl_area` VALUES ('242', '梅州市', '19');
INSERT INTO `tbl_area` VALUES ('243', '汕尾市', '19');
INSERT INTO `tbl_area` VALUES ('244', '河源市', '19');
INSERT INTO `tbl_area` VALUES ('245', '阳江市', '19');
INSERT INTO `tbl_area` VALUES ('246', '清远市', '19');
INSERT INTO `tbl_area` VALUES ('247', '东莞市', '19');
INSERT INTO `tbl_area` VALUES ('248', '中山市', '19');
INSERT INTO `tbl_area` VALUES ('249', '潮州市', '19');
INSERT INTO `tbl_area` VALUES ('250', '揭阳市', '19');
INSERT INTO `tbl_area` VALUES ('251', '云浮市', '19');
INSERT INTO `tbl_area` VALUES ('252', '南宁市', '20');
INSERT INTO `tbl_area` VALUES ('253', '柳州市', '20');
INSERT INTO `tbl_area` VALUES ('254', '桂林市', '20');
INSERT INTO `tbl_area` VALUES ('255', '梧州市', '20');
INSERT INTO `tbl_area` VALUES ('256', '北海市', '20');
INSERT INTO `tbl_area` VALUES ('257', '防城港市', '20');
INSERT INTO `tbl_area` VALUES ('258', '钦州市', '20');
INSERT INTO `tbl_area` VALUES ('259', '贵港市', '20');
INSERT INTO `tbl_area` VALUES ('260', '玉林市', '20');
INSERT INTO `tbl_area` VALUES ('261', '百色市', '20');
INSERT INTO `tbl_area` VALUES ('262', '贺州市', '20');
INSERT INTO `tbl_area` VALUES ('263', '河池市', '20');
INSERT INTO `tbl_area` VALUES ('264', '来宾市', '20');
INSERT INTO `tbl_area` VALUES ('265', '崇左市', '20');
INSERT INTO `tbl_area` VALUES ('266', '海口市', '21');
INSERT INTO `tbl_area` VALUES ('267', '三亚市', '21');
INSERT INTO `tbl_area` VALUES ('268', '重庆市', '22');
INSERT INTO `tbl_area` VALUES ('269', '成都市', '23');
INSERT INTO `tbl_area` VALUES ('270', '自贡市', '23');
INSERT INTO `tbl_area` VALUES ('271', '攀枝花市', '23');
INSERT INTO `tbl_area` VALUES ('272', '泸州市', '23');
INSERT INTO `tbl_area` VALUES ('273', '德阳市', '23');
INSERT INTO `tbl_area` VALUES ('274', '绵阳市', '23');
INSERT INTO `tbl_area` VALUES ('275', '广元市', '23');
INSERT INTO `tbl_area` VALUES ('276', '遂宁市', '23');
INSERT INTO `tbl_area` VALUES ('277', '内江市', '23');
INSERT INTO `tbl_area` VALUES ('278', '乐山市', '23');
INSERT INTO `tbl_area` VALUES ('279', '南充市', '23');
INSERT INTO `tbl_area` VALUES ('280', '眉山市', '23');
INSERT INTO `tbl_area` VALUES ('281', '宜宾市', '23');
INSERT INTO `tbl_area` VALUES ('282', '广安市', '23');
INSERT INTO `tbl_area` VALUES ('283', '达州市', '23');
INSERT INTO `tbl_area` VALUES ('284', '雅安市', '23');
INSERT INTO `tbl_area` VALUES ('285', '巴中市', '23');
INSERT INTO `tbl_area` VALUES ('286', '资阳市', '23');
INSERT INTO `tbl_area` VALUES ('287', '阿坝藏族羌族自治州', '23');
INSERT INTO `tbl_area` VALUES ('288', '甘孜藏族自治州', '23');
INSERT INTO `tbl_area` VALUES ('289', '凉山彝族自治州', '23');
INSERT INTO `tbl_area` VALUES ('290', '贵阳市', '24');
INSERT INTO `tbl_area` VALUES ('291', '六盘水市', '24');
INSERT INTO `tbl_area` VALUES ('292', '遵义市', '24');
INSERT INTO `tbl_area` VALUES ('293', '安顺市', '24');
INSERT INTO `tbl_area` VALUES ('294', '铜仁地区', '24');
INSERT INTO `tbl_area` VALUES ('295', '黔西南布依族苗族自治州', '24');
INSERT INTO `tbl_area` VALUES ('296', '毕节地区', '24');
INSERT INTO `tbl_area` VALUES ('297', '黔东南苗族侗族自治州', '24');
INSERT INTO `tbl_area` VALUES ('298', '黔南布依族苗族自治州', '24');
INSERT INTO `tbl_area` VALUES ('299', '昆明市', '25');
INSERT INTO `tbl_area` VALUES ('300', '曲靖市', '25');
INSERT INTO `tbl_area` VALUES ('301', '玉溪市', '25');
INSERT INTO `tbl_area` VALUES ('302', '保山市', '25');
INSERT INTO `tbl_area` VALUES ('303', '昭通市', '25');
INSERT INTO `tbl_area` VALUES ('304', '丽江市', '25');
INSERT INTO `tbl_area` VALUES ('305', '思茅市', '25');
INSERT INTO `tbl_area` VALUES ('306', '临沧市', '25');
INSERT INTO `tbl_area` VALUES ('307', '楚雄彝族自治州', '25');
INSERT INTO `tbl_area` VALUES ('308', '红河哈尼族彝族自治州', '25');
INSERT INTO `tbl_area` VALUES ('309', '文山壮族苗族自治州', '25');
INSERT INTO `tbl_area` VALUES ('310', '西双版纳傣族自治州', '25');
INSERT INTO `tbl_area` VALUES ('311', '大理白族自治州', '25');
INSERT INTO `tbl_area` VALUES ('312', '德宏傣族景颇族自治州', '25');
INSERT INTO `tbl_area` VALUES ('313', '怒江傈僳族自治州', '25');
INSERT INTO `tbl_area` VALUES ('314', '迪庆藏族自治州', '25');
INSERT INTO `tbl_area` VALUES ('315', '拉萨市', '26');
INSERT INTO `tbl_area` VALUES ('316', '昌都地区', '26');
INSERT INTO `tbl_area` VALUES ('317', '山南地区', '26');
INSERT INTO `tbl_area` VALUES ('318', '日喀则地区', '26');
INSERT INTO `tbl_area` VALUES ('319', '那曲地区', '26');
INSERT INTO `tbl_area` VALUES ('320', '阿里地区', '26');
INSERT INTO `tbl_area` VALUES ('321', '林芝地区', '26');
INSERT INTO `tbl_area` VALUES ('322', '西安市', '27');
INSERT INTO `tbl_area` VALUES ('323', '铜川市', '27');
INSERT INTO `tbl_area` VALUES ('324', '宝鸡市', '27');
INSERT INTO `tbl_area` VALUES ('325', '咸阳市', '27');
INSERT INTO `tbl_area` VALUES ('326', '渭南市', '27');
INSERT INTO `tbl_area` VALUES ('327', '延安市', '27');
INSERT INTO `tbl_area` VALUES ('328', '汉中市', '27');
INSERT INTO `tbl_area` VALUES ('329', '榆林市', '27');
INSERT INTO `tbl_area` VALUES ('330', '安康市', '27');
INSERT INTO `tbl_area` VALUES ('331', '商洛市', '27');
INSERT INTO `tbl_area` VALUES ('332', '兰州市', '28');
INSERT INTO `tbl_area` VALUES ('333', '嘉峪关市', '28');
INSERT INTO `tbl_area` VALUES ('334', '金昌市', '28');
INSERT INTO `tbl_area` VALUES ('335', '白银市', '28');
INSERT INTO `tbl_area` VALUES ('336', '天水市', '28');
INSERT INTO `tbl_area` VALUES ('337', '武威市', '28');
INSERT INTO `tbl_area` VALUES ('338', '张掖市', '28');
INSERT INTO `tbl_area` VALUES ('339', '平凉市', '28');
INSERT INTO `tbl_area` VALUES ('340', '酒泉市', '28');
INSERT INTO `tbl_area` VALUES ('341', '庆阳市', '28');
INSERT INTO `tbl_area` VALUES ('342', '定西市', '28');
INSERT INTO `tbl_area` VALUES ('343', '陇南市', '28');
INSERT INTO `tbl_area` VALUES ('344', '临夏回族自治州', '28');
INSERT INTO `tbl_area` VALUES ('345', '甘南藏族自治州', '28');
INSERT INTO `tbl_area` VALUES ('346', '西宁市', '29');
INSERT INTO `tbl_area` VALUES ('347', '海东地区', '29');
INSERT INTO `tbl_area` VALUES ('348', '海北藏族自治州', '29');
INSERT INTO `tbl_area` VALUES ('349', '黄南藏族自治州', '29');
INSERT INTO `tbl_area` VALUES ('350', '海南藏族自治州', '29');
INSERT INTO `tbl_area` VALUES ('351', '果洛藏族自治州', '29');
INSERT INTO `tbl_area` VALUES ('352', '玉树藏族自治州', '29');
INSERT INTO `tbl_area` VALUES ('353', '海西蒙古族藏族自治州', '29');
INSERT INTO `tbl_area` VALUES ('354', '银川市', '30');
INSERT INTO `tbl_area` VALUES ('355', '石嘴山市', '30');
INSERT INTO `tbl_area` VALUES ('356', '吴忠市', '30');
INSERT INTO `tbl_area` VALUES ('357', '固原市', '30');
INSERT INTO `tbl_area` VALUES ('358', '中卫市', '30');
INSERT INTO `tbl_area` VALUES ('359', '乌鲁木齐市', '31');
INSERT INTO `tbl_area` VALUES ('360', '克拉玛依市', '31');
INSERT INTO `tbl_area` VALUES ('361', '吐鲁番地区', '31');
INSERT INTO `tbl_area` VALUES ('362', '哈密地区', '31');
INSERT INTO `tbl_area` VALUES ('363', '昌吉回族自治州', '31');
INSERT INTO `tbl_area` VALUES ('364', '博尔塔拉蒙古自治州', '31');
INSERT INTO `tbl_area` VALUES ('365', '巴音郭楞蒙古自治州', '31');
INSERT INTO `tbl_area` VALUES ('366', '阿克苏地区', '31');
INSERT INTO `tbl_area` VALUES ('367', '克孜勒苏柯尔克孜自治州', '31');
INSERT INTO `tbl_area` VALUES ('368', '喀什地区', '31');
INSERT INTO `tbl_area` VALUES ('369', '和田地区', '31');
INSERT INTO `tbl_area` VALUES ('370', '伊犁哈萨克自治州', '31');
INSERT INTO `tbl_area` VALUES ('371', '塔城地区', '31');
INSERT INTO `tbl_area` VALUES ('372', '阿勒泰地区', '31');
INSERT INTO `tbl_area` VALUES ('373', '石河子市', '31');
INSERT INTO `tbl_area` VALUES ('374', '阿拉尔市', '31');
INSERT INTO `tbl_area` VALUES ('375', '图木舒克市', '31');
INSERT INTO `tbl_area` VALUES ('376', '五家渠市', '31');
INSERT INTO `tbl_area` VALUES ('377', '香港特别行政区', '32');
INSERT INTO `tbl_area` VALUES ('378', '澳门特别行政区', '33');
INSERT INTO `tbl_area` VALUES ('379', '台湾省', '34');

模型

public function getCityList($pid)
{
   $model = Area::find()->where('parentid =:pid',[':pid'=>$pid])->all();
   return ArrayHelper::map($model,'id','cityname');
}

控制层

public function actionCreate($pid=0,$typeid=1)
    {     
        $pid = (int)Yii::$app->request->get('pid');
        $typeid = (int)Yii::$app->request->get('typeid');
        $model  = new Shop();
        $model->getCityList($pid);
        if($typeid == 1){
            Yii::$app->response->format = Response::FORMAT_JSON;   
            return $model->getCityList($pid);
        }
        return $this->render('create',['model'=>$model]);
    }

视图

 <?= Html::activeDropDownList($model,'province', $model->getCityList(0),
['prompt'=>'--请选择省--','onchange'=>'$.post("'.yii::$app->urlManager->createUrl('shop/create').'&typeid=1&pid="+$(this).val(),function(data){var str="";$.each(data,function(k,v){str+="<option value="+v+">"+v+"</option>";});$("select#shop-city").html(str);})']);?>

<?= Html::activeDropDownList($model,'city', $model->getCityList($model->province),['prompt'=>'--请选择市--']);?>

控制层中需要引用use yii\web\Response;
模型中需要引用use yii\helpers\ArrayHelper;

觉得很赞
您需要登录后才可以回复。登录 | 立即注册
在线
222