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


$userid=$_SESSION["userid"];
$today=date("d-m-Y");
$month_name=$_POST["month_name"];
$amount=$_POST["amount"];
$rollno=$_POST["std_rollno"];
$class_name=$_POST["class_name"];
$sdt_name=$_POST["sdt_name"];
$rt=$_POST["rt"];
$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);

    $sql = "select * from admission 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);
   $bal=$app["sec_fee"];
   $class_name=$app["class_name"];
  $tbal=$bal - $amount ;

	$sql2="update admission set sec_fee='$tbal' where class_name='$class_name' and std_rollno='$rollno' and user_id='$userid';";
	mysql_query($sql2) or die("Error : " . mysql_error());
	
	/*$sql4 = "Insert into std_ledger1 (id,date,rollno,stdname,fname,cname,monthname,issue,rec,balacne,user_id) values (null,'$today','$rollno','$sdt_name','$fname','$class_name','$month_name','0','$amount','0','$userid')";
mysql_query($sql4) or die("Error : " . mysql_error());

$sql3 = "Insert into rec_fee (id,date,std_rollno,std_name,class_name,month_name,total_fee,paid_fee,bal_fee,user_id,rt) values (null,'$today','$rollno','$sdt_name','$class_name','$month_name','$bal','$amount','$tbal','$userid','$rt')";
mysql_query($sql3) or die("Error : " . mysql_error());
	
	
	$sql23="select * from rec_fee where class_name='$class_name' and std_rollno='$rollno' and month_name= '$month_name' and date= '$today' and user_id='$userid'";
$issueslip23=mysql_query($sql23) or die("Error : " . mysql_error());
while($ppp=mysql_fetch_array($issueslip23))

*/

	
	}
else
{
echo "wrong student rollno and name";
}
?>
<br />
<br />
<a href="rec_fee.php">back</a>&nbsp;&nbsp;&nbsp;Account Sign__________