<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <script src="city.js"></script> <script> var i = 0; var j = 0; var k = 0; var sqlstring=""; for( i = 0; i < cityData.length;i++ ){ // console.log(cityData[i].name,cityData[i].id); // 市 sqlstring="INSERT INTO tbCity(FType,FName,FParentId,FCityId) VALUES(0,‘" + cityData[i].name +"‘,0,"+cityData[i].id+");"; console.log(sqlstring); var cityList = cityData[i].cityList; for( j = 0; j < cityList.length;j++ ){ //console.log("=============>",cityList[j].name,cityList[j].id); sqlstring="INSERT INTO tbCity(FType,FName,FParentId,FCityId) VALUES(1,‘" + cityList[j].name +"‘,"+cityList[j].pid+","+cityList[j].id+");"; console.log(sqlstring); // 区 var districtList = cityList[j].districtList; for(k = 0; k < districtList.length;k++ ){ // console.log("++++++++++++++++++++++>",districtList[k].name,districtList[k].id); sqlstring="INSERT INTO tbCity(FType,FName,FParentId,FCityId) VALUES(2,‘" + districtList[k].name +"‘,"+districtList[k].pid+","+districtList[k].id+");"; console.log(sqlstring); } } } console.log("count=",i); </script> </body> </html>
原文:https://www.cnblogs.com/tinyos/p/9374791.html