<?php
  $id_gallery=mysqli_real_escape_string($mysqli,$_GET["id_gallery"]);
  
  $qrym=mysqli_query($mysqli,"SELECT * FROM m_gallery WHERE id_gallery='$id_gallery'");
  $dtm=mysqli_fetch_array($qrym);
  
  echo "<h4>Nama Album: $dtm[judul]</h4>";

  echo "<h3 align=\"right\" style=\"padding-right:10px\"><a href='?action=add_gallery&id_gallery=$id_gallery' style=\"color:#FF0066\">Tambah Foto</a>|| <a href='?page=ls_album&page_desc=Kelola Album'>Kembali</a></h3>";
  
  $qry=mysqli_query($mysqli, "SELECT * FROM t_gallery WHERE id_gallery='$id_gallery'");
  if(mysqli_num_rows($qry)>0){
    
    $no=1;
    
    echo "<table width='100%' align='center' cellpadding='0' cellspacing='0' border='1' bgcolor='#C4D9FF'>";
    echo "<tr bgcolor='#fffccc'>
        <th width='5%'>No.</th>
        <th width='20%'>File Foto</th>
		<th width='65%'>Keterangan</th>
        <th width='10%'>Opsi</th>
        </tr>"; 
    while($data=mysqli_fetch_array($qry)){
      if(!empty($data["file_foto"])){
        $foto="<img src='../foto_berita/$data[file_foto]' width='160' height='120'/>";
      }else{
        $foto="";
      }
	  
	 
      echo "<tr bgcolor=\"#fffcfc\">
          <td align=\"center\" valign=\"top\">$no</td>
          <td valign=\"top\">$foto</td>
		  <td valign=\"top\">$data[keterangan]</td>
          <td valign=\"top\" align=\"center\"><a href=\"_del_gallery.php?id_gallery=$data[id_gallery]&id=$data[idx]\" onclick=\"return confirm('Yakin akan menghapus foto ini?')\"><img src=\"images/delete.gif\" /></a></td>
          
           </tr>";
      $no++;  
    }
    
    echo "</table>";
  }else{
  
    echo "<table width='100%' align='center' cellpadding='0' cellspacing='0' border='1' bgcolor='#C4D9FF'>";
    echo "<tr bgcolor='#fffccc'>
        <th width='5%'>No.</th>
        <th>File Foto</th>
		<th>Keterangan</th>
        <th width='10%'>Opsi</th>
        </tr>";
    
    echo "<tr>
          <td colspan='4' align='center'>Tidak ditemukan foto...</td>
           </tr>";    
    echo "</table>";
  }
?>