这篇文章主要介绍“如何遍历echsop的region表形成缓存的程序”,在日常操作中,相信很多人在如何遍历echsop的region表形成缓存的程序问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”如何遍历echsop的region表形成缓存的程序”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
创新互联建站主要从事网站建设、做网站、网页设计、企业做网站、公司建网站等业务。立足成都服务三原,十年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:028-86922220如下所示:
header("Content-type: text/html; charset=utf-8"); $con = mysql_connect("localhost","root","root"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ecshop", $con); $result = mysql_query("SELECT * FROM ecs_region where region_type=1"); $data=array(); while($row = mysql_fetch_array($result)) { $data1=array(); $data1["itemName"]=$row["region_name"]; $data1["itemCode"]=$row["region_id"]; $data1["list"]=array(); $data[]=$data1; unset($data1); } foreach ($data as $key => $value) { $result1 = mysql_query("SELECT * FROM ecs_region where parent_id=".$value["itemCode"]); while($row1 = mysql_fetch_array($result1)) { $data1=array(); $data1["itemName"]=$row1["region_name"]; $data1["itemCode"]=$row1["region_id"]; $data1["list"]=array(); $result2 = mysql_query("SELECT * FROM ecs_region where parent_id=".$row1["region_id"]); while($row2 = mysql_fetch_array($result2)) { $data2=array(); $data2["itemName"]=$row2["region_name"]; $data2["itemCode"]=$row2["region_id"]; $data2["list"]=array(); $data2["list"]=$data2["list"]; $data1["list"][]=$data2; unset($data2); } //$data[$key]["list"][]=json_encode($data1); $data[$key]["list"][]=$data1; unset($data1); } } // foreach ($data as $key => $value) { // $data[$key]["list"]=json_encode($data[$key]["list"]); // } put_content(json_encode($data)); function put_content($levelconfig) { $message=" "; $fold = "address_config.php"; $stderr = fopen($fold, 'w+'); fwrite($stderr, $message); fclose($stderr); } mysql_close($con); ?>
到此,关于“如何遍历echsop的region表形成缓存的程序”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联网站,小编会继续努力为大家带来更多实用的文章!