遍历echsop的region表形成缓存的程序实例代码
如下所示:
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="<?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表形成缓存的程序实例代码全部内容了,希望大家多多支持积木网~
ecshop适应在PHP7的修改方法解决报错的实现
ecshop这个系统,到目前也没见怎么推出新版本,如果是新项目,不太建议使用它。不过,因为我一直以来都在使用中,所以不得不更改让其适应PHP新版
php获得文件夹下所有文件的递归算法的简单实例
如下所示:functionmy_scandir($dir){$files=array();if(is_dir($dir)){if($handle=opendir($dir)){while(($file=readdir($handle))!==false){if($file!="."&&$file!=".."){if(is_dir($dir."/".$file)){$files[
PHP递归获取目录内所有文件的实现方法
如下所示:/***递归获取文件夹内所有文件*返回一个TREE结构的文件系统*@paramstring$dir*@paramarray$filter*@returnarray$files*/functionscan_dir($dir,$filter=array()){if(!is_dir(