查看文件: setstreet.php
大小: 9.1 KB
类型: application/octet-stream
<?php require('system/login.php'); ?> <?php require_once('../Connections/BE2.php'); ?> <?php function nf_to_wf($strs ){ //全形半形轉換 $wft = array( '一段', '二段', '三段', '四段', '五段', '六段', '七段', '八段', '九段'); $nft = array( "1段", "2段", "3段", "4段", "5段", "6段", "7段", "8段", "9段"); $a1=str_replace($wft,$nft,$strs); //半形到全形 return $a1; } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { if($_POST['street2']<>'') { mysql_select_db($database_BE2, $BE2); // address_id county district street $query_Rt2 =sprintf( "SELECT * FROM address where address_id=%s",$_POST['street']); $Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error()); $row_Rt2 = mysql_fetch_assoc($Rt2); $totalRows_Rt2 = mysql_num_rows($Rt2); $city2=$row_Rt2['county2'];// '台北市'; $alladdr =$row_Rt2['county'].$row_Rt2['district'].$_POST['street2']; $alladdr2=$row_Rt2['county2'].$row_Rt2['district'].$_POST['street2']; $alladdr3=$row_Rt2['county2'].$_POST['street2']; $updateSQL = sprintf("INSERT INTO address(county,county2,district,street,alladdr,alladdr2,alladdr3)VALUES(%s,%s,%s,%s,%s,%s,%s)", GetSQLValueString($_POST['city'], "text"), GetSQLValueString($city2, "text"), GetSQLValueString($_POST['district'], "text"), GetSQLValueString($_POST['street2'], "text"), GetSQLValueString($alladdr, "text"), GetSQLValueString($alladdr2, "text"), GetSQLValueString($alladdr3, "text")); mysql_select_db($database_BE2, $BE2); mysql_query($updateSQL, $BE2) or die(mysql_error()); mysql_free_result($Rt2); $updateSQL = "update address set img_id=address_id where address_id>42860"; mysql_select_db($database_BE2, $BE2); mysql_query($updateSQL, $BE2) or die(mysql_error()); $_GET['city']=$_POST['city']; $_GET['district']=$_POST['district']; $_GET['street']=$_POST['street2']; echo "<script>alert('街道新增完成 ..');</script>"; } } $city='台北市'; if(isset($_GET['city'])){ $city=$_GET['city']; } mysql_select_db($database_BE2, $BE2); // address_id county district street $query_Rot2 = "SELECT distinct(county) FROM address where 1 order by address_id"; $Rot2 = mysql_query($query_Rot2, $BE2) or die(mysql_error()); $row_Rot2 = mysql_fetch_assoc($Rot2); $totalRows_Rot2 = mysql_num_rows($Rot2); //$city=$row_Rot2['county'];// '台北市'; mysql_select_db($database_BE2, $BE2); // address_id county district street $query_Rat2 = sprintf("SELECT distinct(district) FROM address where county='%s' order by CONVERT(`district` USING big5)",$city); $Rat2 = mysql_query($query_Rat2, $BE2) or die(mysql_error()); $row_Rat2 = mysql_fetch_assoc($Rat2); $totalRows_Rat2 = mysql_num_rows($Rat2); $district=$row_Rat2['district']; if(isset($_GET['district'])){ $district=$_GET['district']; } //$district= //order by CONVERT(`Name` USING big5) mysql_select_db($database_BE2, $BE2); // address_id county district street $query_Rbt2 = sprintf("SELECT address_id,street FROM address where county='%s' AND district='%s' order by CONVERT(`street` USING big5)",$city, $district); $Rbt2 = mysql_query($query_Rbt2, $BE2) or die(mysql_error()); $row_Rbt2 = mysql_fetch_assoc($Rbt2); $totalRows_Rbt2 = mysql_num_rows($Rbt2); $street2=$row_Rbt2['street'] ; if(isset($_GET['street'])){ $street2=$_GET['street']; } ?> <div class="row"> <div class="col-md-12"> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">新街道修編</h3> </div> <form action="" method="post" name="form1" id="form1" > <table align="center"> <tr valign="baseline"> <th width="138" height="38" align="center" valign="middle" nowrap="nowrap"> </th> <th width="112" height="38" align="center" valign="middle" nowrap="nowrap"> </th> <th width="181" align="center" valign="middle" nowrap="nowrap"> </th> <th width="181" align="center" valign="middle" nowrap="nowrap"> </th> </tr> <tr valign="baseline"> <th height="42" align="center" valign="middle" nowrap="nowrap">城市:</th> <td valign="middle" nowrap="nowrap"><span class="font2">街道區域</span>:</td> <td valign="middle" nowrap="nowrap">已存在街道(參考用)</td> <td valign="middle" nowrap="nowrap"> </td> </tr> <tr valign="baseline"> <th height="42" align="center" valign="middle" nowrap="nowrap"><select name="city" id="city" class="form-control placeholder col-xs-12 col-sm-4 mb-4" onchange="Selectcity()"> <? do { ?> <option value="<?= $row_Rot2['county']; ?>" <?= ($row_Rot2['county']==$city)?'selected="selected"':""; ?>> <?= $row_Rot2['county']; ?> </option> <?php } while ($row_Rot2 = mysql_fetch_assoc($Rot2)); ?> </select></th> <td valign="middle"><select name="district" id="district" class="form-control placeholder col-xs-12 col-sm-4 mb-4" onchange="Selectstreet();"> <? $address_name .= $row_Rat2['district'].','; do { ?> <option value="<?= $row_Rat2['district']; ?>" <?= ($row_Rat2['district']==$district)?'selected="selected"':""; ?>> <?= $row_Rat2['district']; ?> </option> <? } while ($row_Rat2 = mysql_fetch_assoc($Rat2)); ?> </select></td> <td valign="middle"><select name="street" id="street" class="form-control placeholder col-xs-12 col-sm-4 mb-4" onchange="show_id()"> <? do { ?> <option value="<?= $row_Rbt2['address_id']; ?>" <?= ($street2==$row_Rbt2['street'])?'selected="selected"':""; ?>> <?= $row_Rbt2['street']; ?> </option> <? } while ($row_Rbt2 = mysql_fetch_assoc($Rbt2)); ?> </select></td> <td valign="middle"> </td> </tr> <tr valign="baseline"> <th height="42" colspan="4" align="center" valign="middle" nowrap="nowrap"> </th> </tr> <tr valign="baseline"> <th height="42" align="center" valign="middle" nowrap="nowrap">城市:</th> <td colspan="3" valign="middle"><span class="font2">街道區域</span>:</td> </tr> <tr valign="baseline"> <th height="42" align="center" valign="middle" nowrap="nowrap"><input name="cityx" type="text" id="cityx" value="<?=$city ?>" size="12" maxlength="24" readonly="readonly" /></th> <td colspan="3" valign="middle"><input name="districtx" type="text" id="districtx" value="<?= $district ?>" size="12" maxlength="24" readonly="readonly" /></td> </tr> <tr valign="baseline"> <th height="42" align="center" valign="middle" nowrap="nowrap">新增街道 名稱:</th> <td colspan="3" valign="middle"><input name="street2" type="text" id="street2" size="24" maxlength="24" /></td> </tr> <tr valign="baseline"> <th height="42" align="center" valign="middle" nowrap="nowrap"> </th> <td valign="middle"> </td> <td valign="middle"> </td> <td valign="middle"> </td> </tr> <tr valign="baseline"> <td height="40" colspan="4" align="center" valign="middle" nowrap="nowrap"><input type="submit" value="新增街道名稱" /></td> </tr> </table> <input type="hidden" name="MM_update" id="MM_update" value="form1" /> <input name="url" type="hidden" id="url" value="<?= isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:''; ?>" /> </form> <div class="clearfix"> </div> <div id="back"><a href="javascript:history.back();"><img src="images/back.gif" alt="回上一頁" title="回上一頁" width="115" height="32" border="0"></a></div> </div> </div> </div> <script type="text/javascript"> function Selectstreet() { var county= $("#city").val(); // $(city).find(':selected')[0].id; var district = $("#district").val(); //.find(':selected')[0].id; $("#districtx").val(district); //.find(':selected')[0].id; $.ajax({ type: 'POST', url: 'SelectstreetApi.php', data: { 'county': county,'district':district }, success: function (data) { // the next thing you want to do var $street = $('#street'); $street.empty(); $("select#street").html(data); show_id(); } }); } function Selectcity() { var county= $("#city").val(); // $(city).find(':selected')[0].id; $("#cityx").val($("#city").val()); $.ajax({ type: 'POST', url: 'SelectcityApi.php', data: {'county': county}, success: function (data) { // the next thing you want to do var $street = $('#street'); $street.empty(); var $district = $('#district'); $district.empty(); $("select#district").html(data); Selectstreet(); } }); } </script> <? mysql_free_result($Rot2); mysql_free_result($Rat2); mysql_free_result($Rbt2); ?>
保存
取消
返回文件列表