<?php
session_start();
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
include"../../../../inc/conn.php";

$id_siswa		= str_replace("'","`",(isset($_POST['id_siswa'])) ? $_POST['id_siswa'] : "");
$kelas			= str_replace("'","`",(isset($_POST['kelas'])) ? $_POST['kelas'] : "");

if($id_siswa[0]==''){
	echo"<script>alert('Tidak ada data siswa yang dipilih !');history.go(-1)</script>";
}else{

$q=mysqli_query($connect,"select * from tb_siswa where id_siswa IN(".implode(",", $id_siswa).")") or die(mysqli_error($connect));
while($r=mysqli_fetch_array($q)){
	$filefoto = md5($r['id_siswa']);
	unlink ("../../../../assets/foto/$filefoto.jpg");
	//$delete2 	= mysqli_query($connect,"delete from tb_presensi where nik='".$r['nik']."'")or die(mysqli_error($connect));
}



$delete1 	= mysqli_query($connect,"delete from tb_siswa where id_siswa IN(".implode(",", $id_siswa).")")or die(mysqli_error($connect));
$delete2 	= mysqli_query($connect,"delete from tb_jawaban where id_siswa IN(".implode(",", $id_siswa).")")or die(mysqli_error($connect));


if($delete1){
	echo"<script>alert('Data berhasil dihapus !');</script>";
	echo"<script>document.location.href='index.php?prefix=datasiswa&kelas=$kelas'</script>";
}else{
	echo"<script>alert('Gagal mengeksekusi perintah ini !');history.go(-1)</script>";
}



}


?>