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


$userid=$_SESSION["userid"];
$month_name=$_POST["month_name"];
$rollno=$_POST["std_rollno"];
$class_name=$_POST["class_name"];
$sql = "select * from admission where std_rollno='$rollno' and class_name='$class_name' and user_id='$userid'";
$data=mysql_query($sql);
$found=mysql_num_rows($data);
$founddata="";
 if($found==1)
 {
 $founddata=mysql_fetch_array($data);
 $sqll = "select * from rec_fee where class_name='$class_name' and std_rollno='$rollno' and month_name='$month_name' and user_id='$userid'";
   $std_ledger11=mysql_query($sqll) or die("Error : " . mysql_error());
   $app1=mysql_fetch_array($std_ledger11);
   $paidfee=$app1["paid_fee"];

     $sql = "select * from std_ledger where class_name='$class_name' and std_rollno='$rollno' and user_id='$userid'";
   $std_ledger=mysql_query($sql) or die("Error : " . mysql_error());
   $app=mysql_fetch_array($std_ledger);
   $monthlyfee=$app["monthly_fee"];
   $cname=$app["class_name"];
  $bal=$monthlyfee + $paidfee ;

	$sql2="update std_ledger set monthly_fee='$bal' where class_name='$class_name' and std_rollno='$rollno' and user_id='$userid';";
	mysql_query($sql2) or die("Error : " . mysql_error());
	
	$sql4 = "delete from std_ledger1 where cname='$class_name' and rollno='$rollno' and monthname='$month_name' and user_id='$userid'";
mysql_query($sql4) or die("Error : " . mysql_error());

$sql3 = "delete from rec_fee where class_name='$class_name' and std_rollno='$rollno' and month_name='$month_name' and user_id='$userid'";
mysql_query($sql3) or die("Error : " . mysql_error());
	
	header("location:del_feereceipt_student.php");
	}
else
{
echo "wrong student rollno ";
}
?>
<a href="del_feereceipt_student.php">Back</a>