<?php

session_start();

include "../db.php";



    $attendance_ref = $_GET["ref"];

    

    // $fetch_a_details_run = mysqli_query($con, "SELECT * FROM attendance WHERE ref = '$attendance_ref'");

    // $a_details_row = mysqli_fetch_assoc($fetch_a_details_run);



    $stu_run = mysqli_query($con, "SELECT * FROM attendance_2 AS a INNER JOIN users AS u ON a.stu_id = u.uid WHERE attendance_ref = '$attendance_ref'");



    $count = 1;

    while ( $stu_rows = mysqli_fetch_assoc($stu_run) ) {



        if ($stu_rows["stu_attendance"] == "A") {

            $preAct = "";

            $absAct = "active";

        } elseif ($stu_rows["stu_attendance"] == "P") {

            $preAct = "active";

            $absAct = "";

        } else {

            $preAct = "";

            $absAct = "";

        }



        ?>

        <div class="row mx-0">

        <div class="col-1">

            <h4 class="badge badge-primary"><?php echo $count; ?></h4>

        </div>

        <div class="col-5">

            <h4><?php echo $stu_rows["uname"]; ?></h4>

        </div>

        <div class="col-6 text-right">

            <div class="custom-control custom-radio custom-control-inline">

                <input type="radio" id="radio1<?php echo $count; ?>" name="<?php echo $count; ?>" class="custom-control-input" data-uref='<?php echo $stu_rows["uref"]; ?>'>

                <label class="custom-control-label present attn <?php echo $preAct; ?>" for="radio1<?php echo $count; ?>" data-uref="<?php echo $stu_rows["a_id"]; ?>" data-attn="P">Present</label>

            </div>

            <div class="custom-control custom-radio custom-control-inline">

                <input type="radio" id="radio2<?php echo $count; ?>" name="<?php echo $count; ?>" class="custom-control-input" data-uref='<?php echo $stu_rows["uref"]; ?>'>

                <label class="custom-control-label absent attn <?php echo $absAct; ?>" for="radio2<?php echo $count; ?>" data-uref="<?php echo $stu_rows["a_id"]; ?>" data-attn="A">Absent</label>

            </div>

        </div>

        </div>

        <hr>

        <?php

        $count++;

    }

?>