<?php require('system/login.php');  ?>
<?php require_once('../Connections/BE2.php'); ?>
<?php

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE udat SET ud1=%s, ud2=%s, ud4=%s , ud5=%s WHERE ud0=%s",
                       GetSQLValueString($_POST['ud1'], "text"),
                       GetSQLValueString($_POST['ud2'], "text"),
					   GetSQLValueString($_POST['ud4'], "text"),
					   GetSQLValueString($_POST['ud5'], "int"),
                       GetSQLValueString($_POST['ud0'], "int"));

  mysql_select_db($database_BE2, $BE2);
  $Result1 = mysql_query($updateSQL, $BE2) or die(mysql_error());

  $updateGoTo = $_POST['url'];
  header(sprintf("Location: %s", $updateGoTo));
 
}

$colname_Rt2 = "-1";
if (isset($_GET['id'])) {
  $colname_Rt2 = $_GET['id'];
}
mysql_select_db($database_BE2, $BE2);
$query_Rt2 = sprintf("SELECT * FROM udat WHERE ud0 = %s", GetSQLValueString($colname_Rt2, "int"));
$Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error());
$row_Rt2 = mysql_fetch_assoc($Rt2);
$totalRows_Rt2 = mysql_num_rows($Rt2);
?>
 
<form action="" method="post" name="form1" id="form1">
  <table align="center">
    <tr valign="baseline">
      <th width="146" height="29" align="right" nowrap="nowrap"><span class="font2">合作廠商說明</span>:</th>
      <td width="281"><input name="ud1" type="text" id="ud1" value="<?php echo htmlentities($row_Rt2['ud1'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <th height="29" align="right" nowrap="nowrap"><span class="font2">排列序</span>:</th>
      <td><input name="ud5" type="text" id="ud5" value="<?php echo  $row_Rt2['ud5'] ; ?>" size="32" />
      <input name="ud2" type="hidden" id="ud2" value="<?php echo htmlentities($row_Rt2['ud2'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <th height="27" align="right" nowrap="nowrap"><span class="font2">使用模式</span>:</th>
      <td><select name="ud4" id="ud4">
        <option value="N" <?php if (!(strcmp("Y", $row_Rt2['ud4']))) {echo "selected=\"selected\"";} ?>>N</option>
        <option value="Y" <?php if (!(strcmp("Y", $row_Rt2['ud4']))) {echo "selected=\"selected\"";} ?>>Y</option>
        <? if($myadmin){?>
        <? }?>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">&nbsp;</td>
      <td><input type="submit" value="更新記錄" /></td>
    </tr>
  </table>
  <input type="hidden" name="MM_update" value="form1" />
  <input name="ud0" type="hidden" id="ud0" value="<?php echo $row_Rt2['ud0']; ?>" />
  <input name="url" type="hidden" id="url" value="<? echo $_SERVER['HTTP_REFERER'];?>" />
</form>
 
<?php
mysql_free_result($Rt2);
?>
