<?php
session_start(); 
	$date = new DateTime("now", new DateTimeZone('Africa/Nairobi') );
    $timenow=$date->format('Y-m-d H:i:s');
    $timenow2=$date->format('Y-m-d');
    $iduser=$_SESSION['user_id'];
    
    include('../include/config.php');
    if(isset($_POST['id'])) 
    {
    $id =$_POST['id']; 
    $gr =$_POST['gr'];
    $yr =$_POST['yr'];
    $trm =$_POST['trm'];
    $sql = "SELECT * FROM Fees2 where pid='$id' AND Year='$yr' AND Grad='$gr' AND Term='$trm'";
        $result = $con->query($sql);
        if ($result->num_rows > 0) 
        {
        while($row = $result->fetch_assoc()) 
        {
        $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'];
            
        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';}
        
        $tot=$tu+$bo+$tr+$un+$di+$bk+$moti+$pef+$adm+$tab+$dev;
        ?>	
		<tr>
	         <td>Tution Fee</td>
		     <td><?php echo $row['TutionF']; ?></td>
		</tr>
		<tr>
			<td> Boarding Fee</td>
			<td><?php echo $row['BoF']; ?> </td>
		</tr>
		<tr>
			<td> Admission Fee</td>
			<td><?php echo $row['AdmF']; ?> </td>
		</tr>
		<tr>
			<td> Transport Fee</td>
			<td><?php echo $row['TranF']; ?> </td>
		</tr>
		<tr>
			<td> Motivation Fee</td>
			<td><?php echo $row['MotF']; ?> </td>
		</tr>
		<tr>
			<td> Uniform Fee</td>
			<td><?php echo $row['UniF']; ?> </td>
		</tr>
		<tr>
			<td> Diaries Cost</td>
			<td><?php echo $row['DiariesF']; ?> </td>
		</tr>
		<tr>
			<td>Books</td>
			<td><?php echo $row['TxtF']; ?> </td>
		</tr>
		<tr>
			<td> P. Expenses</td>
			<td><?php echo $row['PEF']; ?> </td>
		</tr>
			<tr>
			<td> Tablet</td>
			<td><?php echo $row['Tablet']; ?> </td>
		</tr>
		
		</tr>
			<tr>
			<td> Development Fee</td>
			<td><?php echo $row['Dev']; ?> </td>
		</tr>
		<tr class="alert-danger">
			<td><strong>Total</strong></td>
			<td><strong><?php echo $tot; ?> </strong></td>
		</tr>
    <?php
	}
	}
	else {
		echo "No results";
	}
		
//	mysqli_close($con);
    }
?>