<?php
session_start();
include 'dbc.php';
$userid=$_SESSION["userid"];
$sql = "select * from 1st_term where user_id='$userid'";
$admission=mysql_query($sql) or die("Error : " . mysql_error());
    
while($app=mysql_fetch_array($admission))
{
  
   $id=$app["id"];
   $total_mark=$app["total_mark"];
   $pass_mark=$app["pass_mark"];
   $obt_mark=$app["obt_mark"];
   
   $per=$obt_mark / $total_mark * 100;
if ($obt_mark >= $pass_mark)
{
$status="Pass";
}
else
{
$status="Fail";
}

if ($per >= 90)
{
$grd="A+";
$remk="Outstanding";
}
elseif ($per >= 80)
{
$grd="A";
$remk="Excellent";
}
elseif ($per >= 70)
{
$grd="B";
$remk="V.Good";
}
elseif ($per >= 60)
{
$grd="C";
$remk="Good";
}
elseif ($per >= 50)
{
$grd="D";
$remk="Fair";
}
elseif ($per >= 40)
{
$grd="E";
$remk="Week";
}
else
{
$grd="F";
$remk="Fail";
}




	$query = "UPDATE 1st_term SET per='$per', status='$status', grade='$grd', remarks='$remk' WHERE id='$id'";
mysql_query($query) or die ("Error in query: $query");
	

	 }
	echo "Result Make Sucessfully";
?>
<a href="exam_Report1.php">Back</a>