<?php require_once('../Connections/BE2.php'); ?>
<?php


if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
	
  $updateSQL = sprintf("update c_adpic set flag='%s',doc='%s',link='%s',ind='%s',imgtxt='%s',linktag='%s',sdate='%s',edate='%s',bman='%s' WHERE id='%s'",$_POST['flag'],$_POST['doc'],$_POST['link'],$_POST['ind'],$_POST['imgtxt'],$_POST['linktag'],$_POST['sdate'],$_POST['edate'],$_POST['bussman'],$_POST['id']);
  mysql_select_db($database_BE2, $BE2);
  $Result1 = mysql_query($updateSQL, $BE2) or die(mysql_error());  
	
  $updateGoTo = $_POST['url'];
  header(sprintf("Location: %s", $updateGoTo));
}

$bid=-1;
if(isset($_GET['id'])){
	$bid=$_GET['id'];
	}  
if($bid<0){ exit;}

mysql_select_db($database_BE2, $BE2);
$query_Rt2 = sprintf("select * from c_adpic WHERE xid='%s'",$bid);
$Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error());
$row_Rt2 = mysql_fetch_assoc($Rt2);
$totalRows_Rt2  = mysql_num_rows($Rt2);  
if($row_Rt2['id']=="" ){
  $insertSQL = sprintf("insert into c_adpic (xid) VALUES('%s')",$bid);
  mysql_select_db($database_BE2, $BE2);
  $Result1 = mysql_query($insertSQL, $BE2) or die(mysql_error());  
  
  $query_Rt2 = sprintf("select * from c_adpic WHERE xid='%s'",$bid);
  mysql_select_db($database_BE2, $BE2);
  $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 border="0" align="center" cellpadding="0" cellspacing="0">
 
    <tr >
      <td width="10">&nbsp;</td>
      <td width="135"><input name="doc" type="hidden" id="doc" value="<? echo $row_Rt2['doc'];?>" />
      <input name="bid" type="hidden" id="bid" value="<? echo $row_Rt2['c0'];?>" />
      <input name="img" type="hidden" id="img" value="<? echo $row_Rt2['img'];?>" />
      <input name="imgext" type="hidden" id="imgext" value="<? echo $row_Rt2['imgext'];?>" /></td>
      <td width="183"><input name="link" type="hidden" id="link" value="" size="40" />
      <input name="sdate" type="hidden" id="sdate" value="<? echo $row_Rt2['sdate'];?>" />
      <input name="edate" type="hidden" id="edate" value="<? echo $row_Rt2['edate'];?>" /></td>
      <td width="33"><label for="select"></label>
        <input name="linktag" type="hidden" id="linktag" value="_self" />
            </td>
      <td width="160"><input name="ind" type="hidden" id="ind" value="100" />
      <input name="bussman" type="hidden" id="bussman" value="1" /></td>
      <td width="171"><input name="flag" type="hidden" id="flag" value="Y" /></td>
    </tr>
</table> 
 
 
  
  
  
  <table width="71%" align="center">
    <tr valign="baseline">
      <td align="center" valign="top" nowrap="nowrap">
        <textarea name="imgtxt" id="imgtxt" rows=30 cols=70 class="ckeditor"><?php echo htmlentities($row_Rt2['imgtxt'], ENT_COMPAT, 'utf-8'); ?></textarea></td>
    </tr>
    <tr valign="baseline">
      <td align="center" nowrap="nowrap"><input type="submit" value="更新記錄" /></td>
    </tr>
  </table>
  <input type="hidden" name="MM_update" value="form1" />
  <input type="hidden" name="id" value="<?php echo $row_Rt2['id']; ?>" />
  <input name="url" type="hidden" id="url" value="<? echo $_SERVER['HTTP_REFERER'];?>" />
</form>
 
<?php
mysql_free_result($Rt2);
?>
