遍历echsop的region表形成缓存的程序实例代码

前端之家收集整理的这篇文章主要介绍了遍历echsop的region表形成缓存的程序实例代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

如下所示:

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="<?php \n";
$message.="\$address_config = '";
$message .= $levelconfig;
$message .="';";
$message.="\n?> ";
$fold = "address_config.PHP";
$stderr = fopen($fold,'w+');
fwrite($stderr,$message);
fclose($stderr);
}
MysqL_close($con);
?>

以上就是小编为大家带来的遍历echsop的region表形成缓存的程序实例代码全部内容了,希望大家多多支持编程之家~

猜你在找的PHP相关文章