查看文件: edit_streetshop.php
大小: 11.95 KB
类型: application/octet-stream
<?php require('system/login.php'); ?> <?php require_once('../Connections/BE2.php'); ?> <?php if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $wwwpath='/www2/skybni'; $picpath= "/number_jpg/c_".$_POST['si10b']; $spicpath= "/number_jpgs/c_".$_POST['si10b']; $tfile="fileToUpload1"; $wimgext=''; $img_ext_array=array("jpg","jpeg","png","gif"); if($_FILES[$tfile]["name"]<>''){ $ext= explode('.',$_FILES[$tfile]['name']) ; $imgext=strtolower($ext[count($ext)-1]); //取最後一筆 if(in_array($imgext,$img_ext_array)){ $spic=$wwwpath.$spicpath.".".$imgext; move_uploaded_file($_FILES[$tfile]["tmp_name"],$spic); $chk_file=true; while($chk_file) { if (file_exists($spic)){ $chk_file=false; } } //$pic=$wwwpath.$picpath.".".$imgext; $picn=$wwwpath.$spicpath.".png"; //$extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); switch ($imgext) { case 'jpg': case 'jpeg': $image = imagecreatefromjpeg($spic); break; case 'gif': $image = imagecreatefromgif($spic); break; case 'png': $image = imagecreatefrompng($spic); break; } imagepng($image, $picn); $chk_file=true; $c=time()+10; $ff=0; while($chk_file) { if (file_exists($picn)){ $ff=1; $chk_file=false; } $c1=time(); if($c1>$c){ $chk_file=false; } } if($ff>0){ $repic ='/www2/skybni/number_jpg/c_'.$_POST['si10b'].".png"; $syscall_3b="/usr/local/bin/convert $picn -resize 100x100 -size 100x100 xc:white +swap -gravity center -composite $repic"; $output2=`$syscall_3b`; } } } $updateSQL = sprintf("UPDATE shop5 SET si5=%s, si6=%s, si11=%s, si12=%s, si13=%s, si14=%s, sicf=%s, address_id=%s WHERE si1=%s", GetSQLValueString($_POST['si5'], "text"), GetSQLValueString($_POST['si6'], "text"), GetSQLValueString($_POST['si11'], "text"), GetSQLValueString($_POST['si12'], "text"), GetSQLValueString($_POST['si13'], "text"), GetSQLValueString($_POST['si14'], "text"), GetSQLValueString($_POST['sicf'], "text"), GetSQLValueString($_POST['address_id'], "int"), GetSQLValueString($_POST['si1'], "int")); mysql_select_db($database_BE2, $BE2); $Result1 = mysql_query($updateSQL, $BE2) or die(mysql_error()); $write='資料已更新...'; $updateGoTo = $_POST["url"]; // echo $upSQL; // header(sprintf("Location: %s", $updateGoTo)); echo "<script>alert('".$write."');location.href='".$updateGoTo."';</script>"; } $colname_Rt2 = "-1"; //-1 if (isset($_GET['id'])) { $colname_Rt2 = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']); } mysql_select_db($database_BE2, $BE2); $query_Rt2 = sprintf("SELECT a.*,b.* FROM shop5 as a,address as b where a.address_id =b.address_id AND si1='%s'",$colname_Rt2); $Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error()); $row_Rt2 = mysql_fetch_assoc($Rt2); $totalRows_Rt2 = mysql_num_rows($Rt2); mysql_select_db($database_BE2, $BE2); // address_id county district street $query_Rot2 = "SELECT distinct(county) FROM address where 1 order by county"; $Rot2 = mysql_query($query_Rot2, $BE2) or die(mysql_error()); $row_Rot2 = mysql_fetch_assoc($Rot2); $totalRows_Rot2 = mysql_num_rows($Rot2); mysql_select_db($database_BE2, $BE2); // address_id county district street $query_Rat2 = sprintf("SELECT distinct(district) FROM address where county='%s' order by district",$row_Rt2['county']); $Rat2 = mysql_query($query_Rat2, $BE2) or die(mysql_error()); $row_Rat2 = mysql_fetch_assoc($Rat2); $totalRows_Rat2 = mysql_num_rows($Rat2); $district=$row_Rt2['district']; 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 street",$row_Rt2['county'], $district); $Rbt2 = mysql_query($query_Rbt2, $BE2) or die(mysql_error()); $row_Rbt2 = mysql_fetch_assoc($Rbt2); $totalRows_Rbt2 = mysql_num_rows($Rbt2); ?> <form action="" method="post" name="form1" id="form1" enctype="multipart/form-data"> <table width="802" align="center"> <tr valign="baseline"> <td height="22" align="right" nowrap><span class="font2">商店名稱:</span></td> <td> <input name="si5" type="text" id="si5" value="<?= $row_Rt2['si5'] ?>" maxlength="4" /> <input type="button" value="尋找商店 ID" onclick="showshop()" /></td> <td> </td> </tr> <tr valign="baseline"> <td width="98" align="right" nowrap><span class="font2">商店ID</span>:</td> <td width="517"><input type="text" name="si10b" id="si10b" value="<?= $row_Rt2['si10b'] ?>" readonly="readonly" /></td> <td width="11"> </td> </tr> <tr valign="baseline"> <td nowrap align="right"><span class="font2">公司地址:</span></td> <td><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']==$row_Rt2['county'])?'selected="selected"':""; ?>> <?= $row_Rot2['county']; ?> </option> <?php } while ($row_Rot2 = mysql_fetch_assoc($Rot2)); ?> </select> </td> <td> </td> </tr> <tr valign="baseline"> <td nowrap align="right"><span class="font2"> </span></td> <td><select name="district" id="district" class="form-control placeholder col-xs-12 col-sm-4 mb-4" onchange="Selectstreet();"> <? do { ?> <option value="<?= $row_Rat2['district']; ?>" <?= ($row_Rat2['district']==$row_Rt2['district'])?'selected="selected"':""; ?>> <?= $row_Rat2['district']; ?> </option> <?php } while ($row_Rat2 = mysql_fetch_assoc($Rat2)); ?> </select></td> <td> </td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><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']; ?>" <?= ($row_Rbt2['street']==$row_Rt2['street'])?'selected="selected"':""; ?>> <?= $row_Rbt2['street']; ?> </option> <?php } while ($row_Rbt2 = mysql_fetch_assoc($Rbt2)); ?> </select></td> <td> </td> </tr> <tr valign="baseline"> <td nowrap align="right"><span class="font2">巷:</span></td> <td><input id="si11" name="si11" type="text" class="form-control g-color-black g-bg-white g-bg-white--focus g-brd-gray-light-v4 g-brd-primary--hover rounded g-py-10 g-px-15" placeholder="請輸入巷" value="<?= $row_Rt2['si11'] ?>" /></td> <td> </td> </tr> <tr valign="baseline"> <td nowrap align="right"><span class="font2">弄:</span></td> <td><input id="si2" name="si2" type="text" class="form-control g-color-black g-bg-white g-bg-white--focus g-brd-gray-light-v4 g-brd-primary--hover rounded g-py-10 g-px-15" placeholder="請輸入弄" value="<?= $row_Rt2['si12'] ?>" /></td> <td> </td> </tr> <tr valign="baseline"> <td nowrap align="right"><span class="font2">號:</span></td> <td><input id="si13" name="si13" type="text" required="required" class="form-control g-color-black g-bg-white g-bg-white--focus g-brd-gray-light-v4 g-brd-primary--hover rounded g-py-10 g-px-15" placeholder="請輸入路號" value="<?= $row_Rt2['si13'] ?>" onchange="show_id()"/> 號</td> <td> </td> </tr> <tr valign="baseline"> <td nowrap align="right"><span class="font2">樓:</span></td> <td><input id="si14" name="si14" type="text" class="form-control g-color-black g-bg-white g-bg-white--focus g-brd-gray-light-v4 g-brd-primary--hover rounded g-py-10 g-px-15" placeholder="請輸入之樓號" value="<?= $row_Rt2['si14'] ?>" onchange="show_id()"/> 樓 <input id="si6" name="si6" type="hidden" value="<?= $row_Rt2['si6'] ?>" /></td> <td> </td> </tr> <tr valign="baseline"> <td nowrap align="right"> <span class="font2">啟用:</span></td> <td><span class="col-md-9"> <select name="sicf" id="sicf" class="form-control placeholder col-xs-12 col-sm-4 mb-4" > <option value="Y" <?= ($row_Rt2['sicf']=='Y')?'selected="selected"':""; ?>>啟用 Y</option> <option value="N" <?= ($row_Rt2['sicf']=='N')?'selected="selected"':""; ?>>停用 N</option> </select> </span></td> <td> </td> </tr> <tr valign="baseline"> <td nowrap align="right"><span class="font2"><img src="/number_jpg/c_<?= $row_Rt2['si10b'] ?>.png" width="100" height="100" /> </span></td> <td><input name="fileToUpload1" type="file" id="fileToUpload1" /> PS 圖: 100px X 100px PNG,JPG</td> <td> </td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input type="hidden" name="si1" id="si1" value="<?= $row_Rt2['si1'] ?>" /> <input type="hidden" name="MM_update" value="form1" /> <input name="url" type="hidden" id="url" value="<?php echo $_SERVER['HTTP_REFERER']; ?>" /> <input id="address_id" name="address_id" type="hidden" value="<?= $row_Rt2['address_id'] ?>" readonly="readonly" /></td> <td> </td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input type="submit" value="更新記錄" /></td> <td> </td> </tr> </table> </form> <script> function Selectstreet() { var county= $("#city").val(); // $(city).find(':selected')[0].id; var district = $("#district").val(); //.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); } }); } function Selectcity() { var county= $("#city").val(); // $(city).find(':selected')[0].id; $.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(); } }); } function show_id(){ //var s=$('#city').find(":selected").text(); var s=$('#city').val() +$('#district').val()+$.trim($('#street').find(":selected").text()); //$('#aioConceptName :selected').text(); // var county= $("#city").val(); s=s+$('#si13').val()+'號'; if($('#si14').val()!=''){ s=s+$('#si14').val()+'樓'; } $('#si6').val(s); $('#address_id').val($('#street').val()); // alert(1); } function showshop(){ // alert(1); var s=$('#si5').val(); $.ajax({ type: 'POST', url: 'SelectcompanyId.php', data: { 'company_title': s }, success: function (data) { // the next thing you want to do if(data>0){ $("#si10b").val(data); alert('找到 ID ..') } else { alert('找不到 ID :'+s); }; } }); } </script> <?php mysql_free_result($Rt2); mysql_free_result($Rot2); mysql_free_result($Rat2); mysql_free_result($Rbt2); ?>
保存
取消
返回文件列表