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

$userid=$_SESSION["userid"];
$today=date("d-m-Y");
$month_name=$_POST["month_name"];
$due_date=$_POST["due_date"];
$amount=$_POST["amount"];
$class_name=$_POST["class_name"];
$sql = "select * from admission where class_name='$class_name' and user_id='$userid'";
$admission=mysql_query($sql) or die("Error : " . mysql_error());
    
while($ppp=mysql_fetch_array($admission))
{
$rollno=$ppp["std_rollno"];
$stdname=$ppp["std_name"];
$fname=$ppp["father_name"];
$code=$ppp["code"];
$mfee=$ppp["monthly_fee"];
$gfee=$ppp["sec_fee"];
$stbal=$ppp["anbal"];
$camp=$ppp["camp"];

    
   $tbal=$amount + $stbal
  
	$sql2="update admission set anbal='$tbal' where std_rollno='$rollno' and class_name='$class_name' and user_id='$userid';";
	mysql_query($sql2) or die("Error : " . mysql_error());
	
	$sql3 = "Insert into issueslipan (id,date,due_date,rollno,stdname,fname,cname,monthname,mfee,afee,total,bal,nettotal,user_id) values (null,'$today','$due_date','$rollno','$stdname','$fname','$class_name','$month_name','$amount','0','$amount','$stbal','$tbal','$userid')";
mysql_query($sql3) or die("Error : " . mysql_error());



	 }
	echo "Slip Genrate Sucessfully";
?>
<a href="genrate_feeslip_an.php">Back</a>