<?php /* 作者:pkkgu; 应用:PHP 读取js省市区地址库 用于前台列表结合项筛选; $type 0 省 $type 1 市 $type 2 区 $num 省为空,市或区时值为市或区的编号 函数放到 userfun.php */ function read_file_content($type=0,$num='') { if($type==0){ $FileName="skin/peiyou/js/city/js/json-array-of-province.js"; $len=6; } elseif($type==1){ $FileName="skin/peiyou/js/city/js/json-array-of-city.js"; $len=2; } elseif($type==2){ $FileName="skin/peiyou/js/city/js/json-array-of-district.js"; $len=4; } //open file $fp=fopen($FileName,"r"); $data=""; while(!feof($fp)) { //read the file $data.=fread($fp,4096); } //close the file fclose($fp); //delete the file //unlink($FileName); //return the content from the file $ret=''; $data=json_decode($data); for($i=0;$i<count($data);$i++){ if($type==0||($type!=0&&substr($num,0,$len)==substr($data[$i]->code,0,$len))){ $ret.="##".$data[$i]->name.','.$data[$i]->code; } } return $ret; //echo $data; } ?>
<?php //前台列表模版应用 $fieldandval=array(); // functiong read_file_content userfun.php $getpro=(int)$_GET['pro']; $profvar=',pro'; $proval=read_file_content(); $fieldandval['pro']='<SPAN>省:</SPAN>|==|全部,'.$proval; $cityfvar=''; $townfvar=''; if($getpro){ $cityfvar=',city'; $cityval=read_file_content(1,$getpro); $fieldandval['city']='<SPAN>市:</SPAN>|==|全部,'.$cityval; $getcity=(int)$_GET['city']; if($getcity){ $townfvar=',town'; $townval=read_file_content(2,$getcity); $fieldandval['town']='<SPAN>县:</SPAN>|==|全部,'.$townval; } } //要显示的结合项字段列表,多个字段用半角逗号“,”隔开zjyx $fieldandvar='sex,zjyx'.$profvar.$cityfvar.$townfvar; //字段显示选项设置,多项用双“#”号隔开,格式:选项说明|==|内容1,值1##内容2,值2 $fieldandval['sex']='<SPAN>性别要求:</SPAN>|==|全部,##男,男##女,女'; $fieldandval['zjyx']='<SPAN>陪伴类型:</SPAN>|==|全部,##私人陪游,商务陪游##交友陪游,异国陪游'; $fieldandval['price']='<SPAN>求聘报酬:</SPAN>|==|全部,##免费,免费##面议,面议##200元以上/天,200元以上/天##1000-3000元/月,1000-3000元/月##3000-6000元/月,3000-6000元/月##6000元以上/月,6000元以上/月'; user_ShowFieldandChange($fieldandvar,$fieldandval); ?>
<!-- 模型字段HTMl 后台 注意:模型需要加6个字段(三个用于存中文) --> <script src="/skin/peiyou/js/city/js/script.js" type="text/javascript"></script> <select id="pro" name="pro"> <option value="0">请选择省份</option> </select> <select id="city" name="city"> <option value="0">请选择城市</option> </select> <select id="town" name="town"> <option value="0">请选择区县</option> </select> <!--下列为初始值(可选,编辑表单时设置)--> <input type="hidden" value="<?=$ecmsfirstpost==1?"":ehtmlspecialchars(stripSlashes($r[pro]))?>" id="pre_pro"/> <input type="hidden" value="<?=$ecmsfirstpost==1?"":ehtmlspecialchars(stripSlashes($r[city]))?>" id="pre_city"/> <input type="hidden" value="<?=$ecmsfirstpost==1?"":ehtmlspecialchars(stripSlashes($r[town]))?>" id="pre_town"/> <!--下列为中文说明--> <input type="hidden" value="<?=$ecmsfirstpost==1?"":ehtmlspecialchars(stripSlashes($r[pro1]))?>" id="pro1" name="pro1" /> <input type="hidden" value="<?=$ecmsfirstpost==1?"":ehtmlspecialchars(stripSlashes($r[city1]))?>" id="city1" name="city1" /> <input type="hidden" value="<?=$ecmsfirstpost==1?"":ehtmlspecialchars(stripSlashes($r[town1]))?>" id="town1" name="town1" /> <!-- 模型字段HTMl 前台 注意:模型需要加6个字段(三个用于存中文) --> <script src="/skin/peiyou/js/city/js/script.js" type="text/javascript"></script> <select id="pro" name="pro"> <option value="0">请选择省份</option> </select> <select id="city" name="city"> <option value="0">请选择城市</option> </select> <select id="town" name="town"> <option value="0">请选择区县</option> </select> <!--下列为初始值(可选,编辑表单时设置)--> <input type="hidden" value="<?=$ecmsfirstpost==1?"":DoReqValue($mid,'town',stripSlashes($r[pro]))?>" id="pre_pro"/> <input type="hidden" value="<?=$ecmsfirstpost==1?"":DoReqValue($mid,'town',stripSlashes($r[city]))?>" id="pre_city"/> <input type="hidden" value="<?=$ecmsfirstpost==1?"":DoReqValue($mid,'town',stripSlashes($r[town]))?>" id="pre_town"/> <!--下列为中文说明--> <input type="hidden" value="<?=$ecmsfirstpost==1?"":DoReqValue($mid,'town',stripSlashes($r[pro1]))?>" id="pro1" name="pro1" /> <input type="hidden" value="<?=$ecmsfirstpost==1?"":DoReqValue($mid,'town',stripSlashes($r[city1]))?>" id="city1" name="city1" /> <input type="hidden" value="<?=$ecmsfirstpost==1?"":DoReqValue($mid,'town',stripSlashes($r[town1]))?>" id="town1" name="town1" />