<style>
table {
    width: 100%;
    border-collapse: collapse;
}

td {
    width: 88px;
    padding: 8px;
    border: 1px solid #000;
}

td:nth-child(2) {
    width: 133px;
}
</style>





<?php
/* find total id */
$link = mysqli_connect("localhost", 'tslibrary_user', 'rb!tsl838', 'tslibrary_data');
 
// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}
 
// Attempt select query execution
$sql = "SELECT * FROM student_registration where drop_out='NO'";
if($result = mysqli_query($link, $sql)){
    if(mysqli_num_rows($result) > 0){
        $countid=0;

        while($row = mysqli_fetch_array($result))
		{
		$studentid=$row['student_id'];
		$totalid[]=$studentid;
		
		$stud_name=$row['name'];
		$std_name[]=$stud_name;
		
		
		$stud_mobile=$row['mobile'].','.$row['mobile1'];
		$std_mobile[]=$stud_mobile;
		
		$fees_amount=$row['fees_amount'];
		$std_fees[]=$fees_amount;
		
		$fees_deposit_date=$row['reg_date'];
		$std_regdate[]=$fees_deposit_date;
		
		$fees_deposit_month=$row['reg_month'];
		$std_regmonth[]=$fees_deposit_month;
		
		$fees_deposit_year=$row['reg_year'];
		$std_regyear[]=$fees_deposit_year;
		
		$seat_no=$row['table_no'];
		$seatno[]=$seat_no;
		
		$batch_no=$row['batch_time'];
		$batchno[]=$batch_no;
		
		$countid=$countid+1;

        }

        // Free result set
        mysqli_free_result($result);
    } else{
        echo "No records matching your query were found.";
    }
} else{
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
 
// Close connection
mysqli_close($link);
?>
<h2>Student Details Not Paid Fees</h2>
<?php
// Fees
$link = mysqli_connect("localhost", 'tslibrary_user', 'rb!tsl838', 'tslibrary_data');
 
// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}
echo '<table style="width: 100%" >';
echo '<tr style="background-color: white;">';
echo '<td style="width: 88px">Student ID</td>';
echo '<td style="width: 88px">Name</td>';
echo '<td style="width: 88px">Seat</td>';
echo '<td style="width: 88px">Batch</td>';
echo '<td style="width: 88px">Mobile</td>';
echo '<td style="width: 133px">Month Name</td>';
echo '<td style="width: 133px">Year</td>';
echo '<td style="width: 133px">Amount</td>';
echo '<td style="width: 133px">Payment Date</td>';
echo '<td style="width: 133px">Remaing Days</td>';
echo '<td style="width: 133px">Update</td>';
echo '<td style="width: 133px">Dropout</td>';
echo '</tr>';
$cur_month=date('m'); 
$cur_year = date('Y');
$duefeessr=0;
$srno=1;

 for($i=0; $i<$countid; $i++)
 {
$oneid=$totalid[$i];
$students_name=$std_name[$i];
$students_mobile=$std_mobile[$i];
$student_fees=$std_fees[$i];
$student_regdate=$std_regdate[$i];
$student_regmonth=$std_regmonth[$i];
$student_regyear=$std_regyear[$i];
$findseat=$seatno[$i];
$findbatch=$batchno[$i];
//Attempt select query execution
$sql = "SELECT * FROM monthly_fees WHERE student_id='$oneid' ORDER BY ID DESC LIMIT 1 ";
if($result = mysqli_query($link, $sql))
{
    if(mysqli_num_rows($result) > 0)
	{
        while($row = mysqli_fetch_array($result))
		{
         $feesmonth=$row['fees_month'];
		 $fees_year=$row['fees_year'];
		 $student_id=$row['student_id'];
		 $paid_fees=$row['paid_fees'];
		 $findseat=$seatno[$i];
//oldpayment date
$payment_date = $row['deposit_fees_year'].'/'.$row['deposit_fees_month'].'/'.$student_regdate;

$old_year=$row['fees_year'] ;
$old_month=$row['fees_month'];	 
if($old_month=='12')
 {
	 $newmonths='01';
	 $newyears=$old_year+1;
 }
 else
 {
	 $newmonths=$old_month+1;
	 $newmonths= str_pad($newmonths, 2, '0', STR_PAD_LEFT);
	 $newyears=$old_year;
 }
 
$ind_payment_date = $student_regdate.'/'.$newmonths.'/'.$newyears; // Remove the
$duedate=$newyears .'/'.$newmonths.'/'.$student_regdate; 
$expdate2=date('Y/m/d',strtotime($duedate)); 
$expdate3=date('Y/m/d');

$date1=date_create($expdate2);
$date2=date_create($expdate3);
$diff=date_diff($date2,$date1);
$dayscount=$diff->format("%R%a");
if($dayscount<-29)
{
	$monthcounter=1;
	
}
echo '<tr>';
echo '<td style="width: 88px">'.$srno.'</td>';
echo '<td style="width: 88px">'.$oneid.'</td>';
echo '<td style="width: 88px">'.$students_name.'</td>';
echo '<td style="width: 88px">'.$findseat.'</td>';
echo '<td style="width: 88px">'.$findbatch.'</td>';
echo '<td style="width: 88px">'.$students_mobile.'</td>';
echo '<td style="width: 133px">'.$cur_month.'</td>';
echo '<td style="width: 133px">'.$cur_year.'</td>';
echo '<td style="width: 133px">'.$student_fees.'</td>';
echo '<td style="width: 133px">'.$ind_payment_date.'</td>';
echo '<td style="width: 133px">'.$dayscount.'</td>';
echo "<td style='width: 133px'><a href='unpaid_status.php?ID=".$oneid. "'>Update</a></td>";
echo "<td style='width: 133px'><a href='viewregistraion.php?ID=".$oneid. "'>Drop out</a></td>";
echo '</tr>'; 
$srno=$srno+1;
		}
        mysqli_free_result($result);
    } else
	{
	
 

    }
} else
{
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}

 }
 echo '</table>'; 
mysqli_close($link);
?>

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.1/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>

</body>
</html>






