<?php
  
  $qry=mysqli_query($mysqli,"SELECT * FROM kontak ORDER BY id DESC");
  
  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>Pesan</th>
        <th width='10%'>Opsi</th>
        </tr>"; 
    while($data=mysqli_fetch_array($qry)){
      echo "<tr bgcolor=\"#fffcfc\">
          <td align=\"center\" valign=\"top\">$no</td>
          <td valign=\"top\">
            <p><b>Pengirim: $data[nama] | <font color='blue'>Email: $data[email] </font> | <font color='red'> Tanggal: $data[tanggal] </font></b></p>
            <p>Isi Pesan:<br/> <font size='2' color='blue'><strong><i>&quot;$data[pesan]&quot;</i></strong></font></p>
          </td>
          
          <td valign=\"top\" align=\"center\"><a href=\"_del_kontak.php?id=$data[id]\" onclick=\"return confirm('Yakin akan menghapus data pesan masuk dari $data[nama] ?')\"><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>Pengumuman</th>
        
        <th width='10%'>Opsi</th>
        </tr>";
    
    echo "<tr>
          <td colspan='3' align='center'>Tidak ditemukan data pengumuman</td>
           </tr>";    
    echo "</table>";
  }
?>