{"id":199534,"date":"2025-05-03T09:20:47","date_gmt":"2025-05-03T01:20:47","guid":{"rendered":"https:\/\/server.hk\/cnblog\/199534\/"},"modified":"2025-05-03T09:20:47","modified_gmt":"2025-05-03T01:20:47","slug":"%e9%81%8d%e5%8e%86ecshop%e7%9a%84region%e8%a1%a8%e5%bd%a2%e6%88%90%e7%bc%93%e5%ad%98%e7%9a%84%e7%a8%8b%e5%ba%8f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/199534\/","title":{"rendered":"\u904d\u5386ecshop\u7684region\u8868\u5f62\u6210\u7f13\u5b58\u7684\u7a0b\u5e8f"},"content":{"rendered":"<p>\u904d\u5386ecshop\u7684region\u8868\u5f62\u6210\u7f13\u5b58\u7684\u7a0b\u5e8f,header(&#8220;Content-type: text\/html; charset=utf-8&#8221;);&nbsp; <\/p>\n<p> $con = mysql_connect(&#8220;localhost&#8221;,&#8221;root&#8221;,&#8221;root&#8221;);<br \/> if (!$con)<br \/> {<br \/> die(&#8216;Could not connect: &#8216; . mysql_error());<br \/> }<\/p>\n<p> mysql_select_db(&#8220;ecshop&#8221;, $con);<\/p>\n<p> $result = mysql_query(&#8220;SELECT * FROM ecs_region where region_type=1&#8221;);<br \/> $data=array();<br \/> while($row = mysql_fetch_array($result))<br \/> {<br \/> $data1=array();<br \/> $data1[&#8220;itemName&#8221;]=$row[&#8220;region_name&#8221;];<br \/> $data1[&#8220;itemCode&#8221;]=$row[&#8220;region_id&#8221;];<br \/> $data1[&#8220;list&#8221;]=array();<br \/> $data[]=$data1;<br \/> unset($data1);<br \/> }<br \/> foreach ($data as $key =&gt; $value) {<br \/> $result1 = mysql_query(&#8220;SELECT * FROM ecs_region where parent_id=&#8221;.$value[&#8220;itemCode&#8221;]);<br \/> while($row1 = mysql_fetch_array($result1))<br \/> {<br \/> $data1=array();<br \/> $data1[&#8220;itemName&#8221;]=$row1[&#8220;region_name&#8221;];<br \/> $data1[&#8220;itemCode&#8221;]=$row1[&#8220;region_id&#8221;];<br \/> $data1[&#8220;list&#8221;]=array();<br \/> $result2 = mysql_query(&#8220;SELECT * FROM ecs_region where parent_id=&#8221;.$row1[&#8220;region_id&#8221;]);<br \/> while($row2 = mysql_fetch_array($result2))<br \/> {<br \/> $data2=array();<br \/> $data2[&#8220;itemName&#8221;]=$row2[&#8220;region_name&#8221;];<br \/> $data2[&#8220;itemCode&#8221;]=$row2[&#8220;region_id&#8221;];<br \/> $data2[&#8220;list&#8221;]=array();<br \/> $data2[&#8220;list&#8221;]=$data2[&#8220;list&#8221;];<br \/> $data1[&#8220;list&#8221;][]=$data2;<br \/> unset($data2);<br \/> }<br \/> \/\/$data[$key][&#8220;list&#8221;][]=json_encode($data1);<br \/> $data[$key][&#8220;list&#8221;][]=$data1;<br \/> unset($data1);<\/p>\n<p> }<br \/> }<br \/> \/\/ foreach ($data as $key =&gt; $value) {<br \/> \/\/ $data[$key][&#8220;list&#8221;]=json_encode($data[$key][&#8220;list&#8221;]);<br \/> \/\/ }<br \/> put_content(json_encode($data));<br \/> function put_content($levelconfig) {<\/p>\n<p> $message=&#8221;&lt;?php \\n&#8221;;<br \/> $message.=&#8221;\\$address_config = &#8216;&#8221;;<br \/> $message .= $levelconfig;<br \/> $message .=&#8221;&#8216;;&#8221;;<br \/> $message.=&#8221;\\n?&gt; &#8220;;<br \/> $fold = &#8220;address_config.php&#8221;;<br \/> $stderr = fopen($fold, &#8216;w+&#8217;);<br \/> fwrite($stderr, $message);<br \/> fclose($stderr);<br \/> }<br \/> mysql_close($con);<br \/> ?&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u904d\u5386ecshop\u7684region\u8868&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-199534","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199534","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=199534"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199534\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=199534"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=199534"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=199534"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}