<?php session_start();
include("connect.php");

////////////////////---- START TO FETCH STUDENT DETAILS
if(isset($_SESSION['stureg_id'])){
	$ddd=mysqli_query($con,"select * from student where id='".$_SESSION['stureg_id']."'");
	$me=mysqli_fetch_assoc($ddd);
	
	$bam=mysqli_query($con,"select * from `programme` where id='".$me['programme_id']."'");
	$pro=mysqli_fetch_assoc($bam);
	
	$bxm=mysqli_query($con,"select * from `department` where id='".$me['dept_id']."'");
	$dep=mysqli_fetch_assoc($bxm);
	
	$bm=mysqli_query($con,"select * from `faculty` where id='".$dep['fac_id']."'");
	$fac=mysqli_fetch_assoc($bm);
	
	$bc=mysqli_query($con,"select * from `semester` where programme_id='".$me['programme_id']."' AND registration_control=1 AND session !='' order by id desc limit 1");
	$sem=mysqli_fetch_assoc($bc);
}
///////////////////--- END FETCH STUDENT DETAILS


if(isset($_POST['signal'])){
	$mac=mysqli_query($con,"select * from course where id='".$_POST['course_id']."'");	
	$cos=mysqli_fetch_assoc($mac);
	
	if($_POST['signal']=='add'){
	echo (((int)$_POST['tnu'])+((int)$cos['unit']));
	}else if ($_POST['signal']=='delete'){
	echo (((int)$_POST['tnu'])-((int)$cos['unit']));
	}else{
	echo ((int)$_POST['tnu']);
	}
}


?>













 