<?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 adpage WHERE pid='%s'",$_GET['del_id']);
$Rt2 = mysql_query($delete_SQL, $BE2) or die(mysql_error());
}


$colname_Rt2 = "-1";
if (isset($_GET['keyword'])) {
  $colname_Rt2 = $_GET['keyword'];
}

$picpath= "/products/";  

mysql_select_db($database_BE2, $BE2);
$sql="";
$query_Rt2 = "SELECT * FROM big5link where aetop='down' order by aeindex";

//$query_Rt2 = "SELECT * FROM adpage where pmid=0 $sql order by pindex";

$Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error());
$row_Rt2 = mysql_fetch_assoc($Rt2);
$totalRows_Rt2  = mysql_num_rows($Rt2); 
?>
 <div class="row">
 <div class="col-md-12">
				
 <div class="panel panel-default">
        <div class="panel-heading">
		   <h3 class="panel-title">新增分頁連結</h3>
        </div>  

    <table cellspacing="1" class="table table-small-font table-bordered table-striped">
    <tr>
      <th width="4%" nowrap="nowrap" class="font2">ID</th>
      <th width="30%" nowrap="nowrap" class="font2">圖片說明</th>
      <th width="29%" nowrap="nowrap" class="font2"> 分頁連結</th>
      <th nowrap="nowrap" class="font2">圖檔</th>
      <th nowrap="nowrap" class="font2">排列序</th>
      <th nowrap="nowrap" class="font2">刪除</th>
    </tr>
    <?php 
	 if($totalRows_Rt2>0){ 
	  do { ?>
    <tr>
      <td align="center" class="font3"><a href="main.php?act=editbig5&amp;id=<?php echo $row_Rt2['ae1']; ?>"><img src="images/edit.png" alt="修改項目名稱" title="修改項目名稱" width="16" height="16" border="0" /></a></td>
      <td align="center" class="font3"><?php echo $row_Rt2['aedoc']; ?></td>
      <td align="center" class="font3"><a href="<?php echo $row_Rt2['aelink']; ?>" target="_blank">
	  <?= (strlen($row_Rt2['aelink'])<40)?$row_Rt2['aelink']:substr($row_Rt2['aelink'],0,30).'....'; ?></a></td>
      <td width="16%" align="center" class="font3">
           <? 
	   $pic=$wwwpath.$picpath.$row_Rt2['aeimg'].".".$row_Rt2['aeimgext'];
	   $img=(file_exists($pic))?$picpath.$row_Rt2['aeimg'].".".$row_Rt2['aeimgext']:""; ?>
      <img src="<?= $img; ?>" alt="圖檔元素" title="圖檔元素" width="32" height="32" />
      </td>
      <td width="13%" align="center" class="font3"><?php echo $row_Rt2['aeindex']; ?></td>
      <td width="8%" align="center" class="font3"><a href="javascript:if(confirm('確實要刪除嗎?'))location='<? echo 'main.php?act=setbig5&del_id='.$row_Rt2['ae1'] ;?>'"><img src="images/del.png" alt="刪除項目" width="16" height="16" border="0"/></a></td>
    </tr>
    <?php } while ($row_Rt2 = mysql_fetch_assoc($Rt2)); 
	 }
	  ?>

  </table>
</div>
 </div>
 </div> 
<?php
mysql_free_result($Rt2);
?>
