<?php require('system/login.php');  ?>
<?php require_once('../Connections/BE2.php'); ?>
<?php
 
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
 
  $ec=explode(",",$_POST['ec1']);
  $insertkid = sprintf("UPDATE tb2city set ec1='%s',ec3='%s',bctaddr='%s',bcttel='%s' WHERE bctid='%s'",$ec[0],$ec[1],$_POST['bctaddr'],$_POST['bcttel'],$_POST['bctid']);
 
   mysql_select_db($database_BE2, $BE2);
   $Result1 = mysql_query($insertkid, $BE2) or die(mysql_error());
 	   
   $write='資料已更新...';
   echo  "<script>alert('".$write."');</script>";
   $updateGoTo =$_POST['url']; 
   header(sprintf("Location: %s", $updateGoTo));
	 
 }


mysql_select_db($database_BE2, $BE2);
$query_Rt2 =sprintf("select a.buid,a.bc2,a.bc3,a.bc4,b.* from tb2 as a,tb2city as b where a.buid=b.buid2 AND  b.bctid= '%s'",$_GET['id']);
$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);
$query_Rt3 = "select * from tb1 where 1 order by tbc0,ec4";
$Rt3 = mysql_query($query_Rt3, $BE2) or die(mysql_error());
$row_Rt3 = mysql_fetch_assoc($Rt3);
$totalRows_Rt3 = mysql_num_rows($Rt3);

//  if($_SERVER['REMOTE_ADDR']=='220.130.43.121'){ echo $query_Rt2;}
?>
<div class="font2"><? echo $row_Rt2['bc2']." ".$row_Rt2['bc3'].$row_Rt2['bc4'] ?></div> 
<div id="content" align="center">
 <form id="form1" name="form1" method="post" action="">
 <table width="46%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <th height="33" align="center" valign="middle" nowrap="nowrap" class="font2">服務城市</th>
          <th valign="middle" nowrap="nowrap" class="font2">服務電話</th>
          <th align="center" valign="middle" class="font2">服務地址</th>
          <th align="center" valign="middle" class="font2">&nbsp;</th>
        </tr>

      <tr>
          <th width="19%" align="center" valign="top" nowrap="nowrap" class="font3"><label for="ec1"></label>
          <select name="ec1" id="ec1">
        <?php do {  ?>
            <option value="<?= $row_Rt3['ec1'].",".$row_Rt3['ec3']?>" <? if($row_Rt3['ec1']==$row_Rt2['ec1']){ echo 'selected="selected"' ;}?>><?= $row_Rt3['ec3']?></option>
        <?php } while ($row_Rt3 = mysql_fetch_assoc($Rt3)); ?>  
        </select></th>
          <td width="23%" align="center" valign="top" class="font3"><input name="bcttel" type="text" id="bcttel" value="<?= $row_Rt2['bcttel']?>" size="20" maxlength="20" /></td>
          <td width="48%" align="center" valign="top" class="font3"><input name="bctaddr" type="text" id="bctaddr" value="<?= $row_Rt2['bctaddr']?>" size="40" maxlength="40" /></td>
          <td width="10%" align="center" valign="top" class="font3">&nbsp;</td>
        </tr>
 
        
        <tr>
          <td height="3" colspan="4" align="center" ><input type="submit" name="button" id="button" value="送出" /></td>
        </tr>
    </table>
      <input type="hidden" name="MM_update" value="form1" />
      <input name="buid" type="hidden" id="buid" value="<?= $_GET['id'];?>" />
    <input name="url" type="hidden" id="url" value="<?= $_SERVER['HTTP_REFERER']; ?>" />
    <input name="bctid" type="hidden" id="bctid" value="<?= $row_Rt2['bctid'];?>" />
 </form>
 
</div>
 

<?php
mysql_free_result($Rt2);
mysql_free_result($Rt3);
?>
