<?php
session_start();
include 'dbc.php';

$userid=$_SESSION["userid"];
$today=date("d-m-Y");
$month_name=$_POST["month_name"];
$amount=$_POST["amount"];
$disc=$_POST["disc"];
$class_name=$_POST["class_name"];
$sql = "select * from issueslip where monthname='$month_name' and cname='$class_name' and user_id='$userid'";
$admission=mysql_query($sql) or die("Error : " . mysql_error());
    
while($ppp=mysql_fetch_array($admission))
{
$rollno=$ppp["rollno"];
$stdname=$ppp["stdname"];
$fname=$ppp["fname"];
$cname=$ppp["cname"];
$code=$ppp["code"];
$nettotal=$ppp["nettotal"];

    
   $tbal=$amount + $nettotal;
   
   $result = mysql_query("SELECT * FROM admission WHERE std_rollno='$rollno' and std_name='$stdname' and class_name='$cname' and user_id='$userid'");
$test = mysql_fetch_array($result);
if (!$result) 
		{
		die("Error: Data not found..");
		}
				$obal=$test['bal'] ;
  $netbal=$amount + $obal;
  
	$sql2="update admission set bal='$netbal' where std_rollno='$rollno' and std_name='$stdname' and class_name='$cname' and user_id='$userid';";
	mysql_query($sql2) or die("Error : " . mysql_error());
	
		
$sql3="update issueslip set nettotal='$tbal',feedisc='$disc',feeamount='$amount' where rollno='$rollno' and stdname='$stdname' and cname='$cname' and monthname='$month_name' and user_id='$userid';";
	mysql_query($sql3) or die("Error : " . mysql_error());
	
	 }
	echo "Fee Genrate Sucessfully";
?>
<a href="genrate_feeslip_fine.php">Back</a>