<?php 
    include('../include/config.php');
    $yr= $_POST["yr"];
    $grade= $_POST["grade"];
    $trm= $_POST["trm"];
    $id=$_POST["id"];
    
    $query=mysqli_query($con,"SELECT * FROM Fees2 WHERE Year='$yr' AND Grad='$grade' AND Term='$trm' AND pid='$id'");
    $num=mysqli_fetch_array($query);
    if($num>0)
    {
        $query2=mysqli_query($con,"SELECT * FROM Fees2 WHERE Year='$yr' AND Grad='$grade' AND Term='$trm' AND pid='$id'");
        while($row=mysqli_fetch_array($query2))
        {
        $tu=$row['TutionF'];
        $bo=$row['BoF'];
        $adm=$row['AdmF'];
        $tr=$row['TranF'];
        $moti=$row['MotF'];
        $un=$row['UniF'];
        $di=$row['DiariesF'];
        $bk=$row['TxtF'];
        $pef=$row['PEF'];
        $tab=$row['Tablet'];
        $dev=$row['Dev'];
        $assbk=$row['Assbok'];
            
        if($tr==''){$tr='0';}
        if($un==''){$un='0';}
        if($moti==''){$moti='0';}
        if($pef==''){$pef='0';}
        if($di==''){$di='0';}
        if($bk==''){$bk='0';}
        if($bo==''){$bo='0';}
        if($adm==''){$adm='0';}
        if($tab==''){$tab='0';}
        if($dev==''){$dev='0';}
        if($assbk==''){$assbk='0';}
        
        $tr = intval($tr);
        $un = intval($un);
        $moti = intval($moti);
        $pef = intval($pef);
        $di = intval($di);
        $bk = intval($bk);
        $bo = intval($bo);
        $adm = intval($adm);
        $tab = intval($tab);
        $tu = intval($tu);
        $dev = intval($dev);
        $assbk= intval($assbk);
        
        $tot=$tu+$bo+$tr+$un+$di+$bk+$moti+$pef+$adm+$tab+$dev+$assbk; 
        }
         echo $tot;
    }else
    {
    echo '0.0';
    }

?>