<?php
$benar = 0;
$qtbsoal=mysqli_query($connect,"select * from tb_essai where id_unit='".$runit['id_unit']."'");
$jumlahsoal=mysqli_num_rows($qtbsoal);
while($rtbsoal=mysqli_fetch_array($qtbsoal)){

	$qjawaban=mysqli_query($connect,"select * from tb_jawaban where id_siswa='".$rsiswa_login['id_siswa']."' AND id_unit='".$runit['id_unit']."' AND id_essai='".$rtbsoal['id_essai']."'");
    $rjawaban=mysqli_fetch_array($qjawaban);

    if($rtbsoal['kunci']==$rjawaban['jawaban']){
    	$benar++;
    }else{
    	$benar = $benar;
    }

}

$skor = round($benar/$jumlahsoal*100,2);
?>

Total skor anda adalah : <b><?php echo $skor;?></b>