<?php

    // session_start();

    include "../db.php";

    $srun = mysqli_query($con, "SELECT uid, uname FROM users WHERE uid = '$_GET[stuid]'");

    $srow = mysqli_fetch_assoc($srun);



    $u_run = mysqli_query($con, "SELECT f.sid, f.amount, f.fmonth, f.fdate, u.uname, u.uid FROM fees  AS f INNER JOIN users AS u ON f.sid = u.uid WHERE f.sid = '$_GET[stuid]'");



    if ( mysqli_num_rows($u_run) > 0 ) {

        echo '

            <div class="row">

                <div class="col-12">

                <h5 class="badge badge-success" style="font-size: 15px">'.$srow["uname"].'</h5>

                    <table class="table table-striped table-hover table-bordered w-100">

                        <thead class="thead-inverse text-center">

                            <tr>

                                <th>SL No</th>

                                <th>Month</th>

                                <th>Fees</th>

                                <th>Date</th>

                            </tr>

                        </thead>

                        <tbody class="text-center">

                            ';

                            // $u_run = mysqli_query($con, "SELECT f.sid, f.amount, f.fmonth, f.fdate, u.uname, u.uid FROM fees  AS f INNER JOIN users AS u ON f.sid = u.uid WHERE f.sid = '$_GET[stuid]'");

                            $a = 1;

                            $totalfees = 0;

                            while ($u_row = mysqli_fetch_assoc($u_run)) {

                                $totalfees += $u_row["amount"];

                                echo '

                                    <tr>

                                        <td>'.$a.'</td>

                                        <td>'.$u_row["fmonth"].'</td>

                                        <td>'.$u_row["amount"].'</td>

                                        <td>'.date('d-m-Y', strtotime($u_row["fdate"])).'</td>

                                    </tr>

                                ';

                                $a++;

                            }

                            // $fees=$fees+$fees;

                        echo '

                            <tr>

                                <td></td>

                                <th>Total Fees =</th>

                                <td>'.$totalfees.'</td>

                                <td></td>

                            </tr>

                        </tbody>

                    </table>

                </div>

            </div>

        ';

    } else {

        echo '

        No fees yet

        ';

    }

    

    

?>

