<?php
if ($_SESSION['status_admin']=='admin04')
{
    if($_POST)
    {
        $cek=count($_POST["item"]);
            if($cek == 0)
            {
                echo "<script>alert('tidak ada data yang terpilih');location.href='?page=data_admin'</script>";
            }
        else
        {
            for($i=0; $i < $cek; $i++)
            {
                $id=$_POST['item'][$i];
                $quer=mysql_query("select*from admin where id_admin='$id'");
                $dt=mysql_fetch_array($quer);
                $target="foto/$dt[foto_admin]";
                unlink($target);
                
                $hps=mysql_query("delete from admin where id_admin='$id'");
              }
            if($hps)
               {
                     echo "<script>alert('Berhasil Menghapus data');location.href='?page=data_admin'</script>";
            
               }
            
        }
    }
$sql="select*from admin where status_admin='admin04' ";	
$result=mysql_query($sql);
$rpp=10;
$reload="?page=data_admin&?pagination1=true";
$pages=isset($_GET["pages"]) ? (intval($_GET["pages"])):1;
$tcount=mysql_num_rows($result);
$tpages=($tcount) ? ceil($tcount/$rpp):1;
$count=0;
$i=($pages-1)*$rpp;
$no_urut =($pages-1)*$rpp;
?>
<style type="text/css">
    p{
        margin-left: 0px;
    }
    @media(max-width:700px){
        p{
        
            text-align: center;
        }
    }
</style>
    <div class="col-md-12">
<div id="bgjdl">
    DATA ADMIN
    </div>
    </div>
<div class="col-md-12" >

    <form action="" method="post">
             <input type="hidden" name="r" value="<?php echo $reload;?>">
            <input type="hidden" name="p" value="<?php echo $pages;?>">
                      
               
           <table  class="table table-striped table-hover table-bordered" id="example1">
          <thead>
          <tr>
                <th id="th" class="info">Pilih</th>
                <th id="th" class="info">NO</th>
                <th id="th" class="info">Nama</th>
                <th id="th" class="info">Username</th>
                <th id="th" class="info">No Hp</th>
                <th id="th" class="info">Alamat</th>
                <th id="th" class="info">Foto</th>
                </tr>
            </thead>
            
            <?php

while (($count<$rpp)&&($i<$tcount)){
    mysql_data_seek($result,$i);
     $data=mysql_fetch_array($result);
    
    ?>
            <tbody>
                <tr align="center" id="tr">
             
                    <td data-content="Pilih" id="td"><input name="item[]" type="checkbox" id="item[]" value="<?php echo $data ['id_admin'];?>" /></td>  
                    <td data-content="No" id="td"><?php echo ++$no_urut;?></td>    
                    <td data-content="nama" id="td"><?php echo $data ['nama_admin'];?></td>    
                    <td data-content="username" id="td"><?php echo $data ['username'];?></td>  
                    <td data-content="no hp" id="td"><?php echo $data ['no_hp_admin'];?></td> 
                    <td data-content="alamat" id="td"><?php echo $data ['alamat_admin'];?></td>    
                    <td data-content="Foto Admin" id="td">
                        <a href="foto/<?php echo $data ['foto_admin'];?>" class="perbesar"><img src="foto/<?php echo $data ['foto_admin'];?>" id="fk" class="img-responisve"></a></td>    
                  
                </tr>
            </tbody>
            <?php
  $i++;
    $count++;
}
          
    ?>
            
            </table>
               <div class="col-md-12">
    <div id="fonthps">Hapus Yang Ditandai <button class="btn btn-danger" type="submit" name="but">
        <i class="fa fa-times"></i> HAPUS
        </button></div>
                   </div>
    </form>
     
    
</body>
</html>
<?php
}
else
{
    echo "<script>alert('ANDA GAGAL MASUK !! ');location.href='?page=home_admin'</script>";
}
?>