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

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

$qsiswa=mysqli_query($connect,"select * from tb_siswa where id_kelas='".$id_kelas."'");
while($rsiswa=mysqli_fetch_array($qsiswa)){
	$deletejawaban = mysqli_query($connect,"delete from tb_jawaban where id_siswa='".$rsiswa['id_siswa']."'")or die(mysqli_error($connect));
}

$delete1 	= mysqli_query($connect,"delete from tb_kelas where id_kelas='$id_kelas'")or die(mysqli_error($connect));
$delete2 	= mysqli_query($connect,"delete from tb_siswa where id_kelas='$id_kelas'")or die(mysqli_error($connect));


if($delete1){
	echo"<script>alert('Kelas berhasil dihapus !');</script>";
	echo"<script>document.location.href='datakelas'</script>";
}else{
	echo"<script>alert('Gagal mengeksekusi perintah ini !');history.go(-1)</script>";
}


?>