<?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'];
    $totalpaid='';
    
    $resultt = mysqli_query($con,"SELECT sum(PaidAmount) as tot  FROM feestatement where pid='$id' AND Year='$yr' AND Term='$trm'");
    while($row = $resultt->fetch_assoc()) 
    {
     $totalpaid=$row["tot"];  
    }
    
    
    $sqll = "SELECT * FROM feestatement where pid='$id' AND Year='$yr' AND Term='$trm'";
        $result = $con->query($sqll);
        if ($result->num_rows > 0) 
        {
        $cnt=1;
        while($row = $result->fetch_assoc()) 
        {
        ?>	
		<tr>
	         <td><?php echo $cnt; ?></td>
	         <td><?php echo $row['BankDate']; ?></td>
		     <td class="alert-success"><strong><?php echo $row['PaidAmount']; ?></strong></td>
		     <td><?php echo $row['EntryDate']; ?></td>
		</tr>
	
    <?php
    $cnt=$cnt+1;
	}
	?>
	  	<tr>
		    <td colspan="2"><strong>Total</strong></td>
		    <td><strong><?php echo $totalpaid; ?></strong></td>
		</tr>
	<?php
	}
	else {
		echo "No results";
	}
		
//	mysqli_close($con);
    }
?>