<?php require('system/login.php');  ?>
<?php require_once('../Connections/BE2.php'); ?>
<?php

if(isset($_GET['del_id']) && ( $_GET['del_id']>0 )){
mysql_select_db($database_BE2, $BE2);
$delete_SQL = sprintf("DELETE FROM adpic WHERE id='%s'",$_GET['del_id']);
$Rt2 = mysql_query($delete_SQL, $BE2) or die(mysql_error());
}
$bid=-1;
if(isset($_GET['id'])){
	$bid=$_GET['id'];
	}  
mysql_select_db($database_BE2, $BE2);
//$query_Rt2 = sprintf("select a.*,b.* from left join adpic WHERE xid='%s'",$bid);
$query_Rt2 = sprintf("select a.*,c.* from adpage as a,ap2 as b left join adpic as c on b.adid=c.xid  WHERE a.pid=b.webid  AND b.adid='%s'",$bid);



$Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error());
$row_Rt2 = mysql_fetch_assoc($Rt2);
$totalRows_Rt2  = mysql_num_rows($Rt2);  
?>
<span class="ti2"><a href="main.php?act=ad2&webid=<?= $row_Rt2['pid']; ?>"><?= $row_Rt2['pdoc']?></a> <a href="main.php?act=ad_browseadd&amp;id=<?php echo $bid; ?>">新增廣告圖檔</a></span>
<?  // if($myadmin){ echo $query_Rt2; }?> 
<table width="765" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <th width="3%" nowrap="nowrap" class="font2">ID</th>
      <th width="18%" nowrap="nowrap" class="font2">圖片說明</th>
      <th width="21%" nowrap="nowrap" class="font2">連結</th>
      <th width="10%" nowrap="nowrap" class="font2">圖檔</th>
      <th width="10%" nowrap="nowrap" class="font2">使用</th>
      <th width="9%" nowrap="nowrap" class="font2">排列序</th>
      <th width="11%" nowrap="nowrap" class="font2">啟用日期</th>
      <th width="11%" nowrap="nowrap" class="font2">截止日期</th>
      <th nowrap="nowrap" class="font2">刪除</th>
    </tr>
    <?php 
	 if($row_Rt2['id']<>""){    
	  do { ?>
    <tr>
      <td align="center" class="font3"><a href="main.php?act=ad_browseedit&amp;id=<?php echo $row_Rt2['id']; ?>"><img src="images/edit.png" alt="修改項目名稱" title="修改項目名稱" width="16" height="16" border="0" /></a></td>
      <td align="center" class="font3"><?php echo $row_Rt2['doc']; ?></td>
      <td align="center" class="font3"><?php echo $row_Rt2['link']; ?></td>
      <td align="center" class="font3"><img src="<?php 
	  //if($row_Rt2['raid']==14){ $img= 'images/youtube.png' ;}else{
		 $img= "/products/".$row_Rt2['img'].'.'.$row_Rt2['imgext'];
		//  }
	  echo $img ; ?>" alt="編輯圖檔元素" title="編輯圖檔元素" width="75" /></td>
      <td align="center" class="font3"><?php echo $row_Rt2['flag']; ?></td>
      <td align="center" class="font3"><?php echo $row_Rt2['ind']; ?></td>
      <td align="center" class="font3"><?php echo $row_Rt2['sdate']; ?></td>
      <td align="center" class="font3"><?php echo $row_Rt2['edate']; ?></td>
      <td width="7%" align="center" class="font3"><a href="javascript:if(confirm('確實要刪除嗎?'))location='<? echo 'main.php?act=ad_browse&id='.$bid.'&del_id='.$row_Rt2['id'] ;?>'"><img src="images/del.png" alt="刪除項目" width="16" height="16" border="0"/></a></td>
    </tr>
    <?php } while ($row_Rt2 = mysql_fetch_assoc($Rt2)); 
	 }
	  ?>
 
    <tr>
      <td colspan="10"></td>
    
    </tr>
  </table>

<?php
mysql_free_result($Rt2);
?>
