Enter multiple rows in an MySQL table by pressing the Submit button in a PHP Form

So to preface – I’m trying to implement a “Mark Attendance” feature on my website where I’m printing all the registered students in a table (that is wrapped in ) – each student has a “Present / Absent” radio button and once the admin has selected his preferred option, he presses “Submit” and the form should mark all students Present OR Absent i.e insert multiple rows (equal to the number of total students in the table) with their Attendance Status i.e Absent or Present.

Following is the HTML part of the code (mixed with some PHP):

<form action="adminmarkattendance.php" method="post">
                                <div class="row">
                                    <div class="col">
                                        <div class="card bg-default shadow">
                                            <div class="card-header bg-transparent border-0">

                                                <div class="form-inline">
                                                    <div class="col-lg-6">
                                                        <h3 class="text-white mb-0">Registered Students</h3>
                                                    </div>
                                                    <div class="col-lg-6">
                                                        <div class="form-group">
                                                            <input style="width: 100%;" class="form-control" name="attendancedate" type="date" required>

                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="table-responsive" style="overflow-y: scroll; height: 600px;">
                                                <table class="table align-items-center table-dark table-flush">
                                                    <thead class="thead-dark">
                                                        <tr>

                                                            <th scope="col" class="sort" data-sort="name">Avatar</th>
                                                            <th scope="col" class="sort" data-sort="name">Student Name</th>
                                                            <th scope="col" class="sort" data-sort="status">Phone Number</th>
                                                            <th scope="col" class="sort" data-sort="status">Age</th>
                                                            <th scope="col" class="sort" data-sort="status">Gender</th>
                                                            <th scope="col" class="sort" data-sort="status">Address</th>
                                                            <th scope="col" class="sort" data-sort="status">Action</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody class="list">
                                                        <?php
                                                        foreach ($getRows as $row) {
                                                            $i = 0; ?>
                                                            <tr>
                                                                <td>
                                                                    <img src="<?php echo '../profileImages/' . $row['profile_image'] ?>" width="45" height="45" alt="">
                                                                    <input type="hidden" name="id" value="<?php echo $row['student_id']; ?>">
                                                                </td>
                                                                <th scope="row">
                                                                    <div class="media align-items-center">

                                                                        <div class="media-body">
                                                                            <span class="name mb-0 text-sm"><?php echo $row['fname'] . ' ' . $row['lname']; ?></span>
                                                                        </div>
                                                                    </div>
                                                                </th>

                                                                <td>
                                                                    <span class="badge badge-dot mr-4">
                                                                        <span class="status"><?php echo $row['phonenumber']; ?></span>
                                                                    </span>
                                                                </td>
                                                                <td>
                                                                    <span class="badge badge-dot mr-4">
                                                                        <span class="status"><?php echo $row['age']; ?></span>
                                                                    </span>
                                                                </td>
                                                                <td>
                                                                    <span class="badge badge-dot mr-4">
                                                                        <span class="status"><?php echo $row['gender']; ?></span>
                                                                    </span>
                                                                </td>
                                                                <td>
                                                                    <span class="badge badge-dot mr-4">
                                                                        <span class="status"><?php echo $row['address']; ?></span>
                                                                    </span>
                                                                </td>
                                                                <td>
                                                                    <div class="btn-group btn-group-toggle" data-toggle="buttons">
                                                                        <label class="btn btn-secondary active">
                                                                            <input type="radio" name="options" value="present" id="option1" autocomplete="off" checked> Present
                                                                        </label>
                                                                        <label class="btn btn-secondary">
                                                                            <input type="radio" name="options" value="absent" id="option2" autocomplete="off"> Absent
                                                                        </label>
                                                                    </div>
                                                                </td>

                                                            </tr>
                                                        <?php } ?>
                                                    </tbody>
                                                </table>

                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="text-center">
                                    <button type="submit" name="submit" style="width: 100%;" class="btn btn-warning">Mark Attendance</button>
                                </div>
                            </form>

PHP:

   if (isset($_POST["submit"])) {

    $student_id = $_POST["id"];
    $date = $_POST['attendancedate'];
    $date = date('Y-m-d', strtotime($date));
    $status = $_POST['options'];

    $queryInsert = $conn->prepare("INSERT
       into attendance
       (
       student_id,
       date,
       status
       )
       values 
       (
       $student_id,
       '$date',
       '$status'
       )
  ");
  $queryInsert->execute();
  

    echo "<script> location.replace('adminmarkattendance.php'); </script>";
}

As you can probably see in the code – I’m only trying to insert the student’s ID, date & his present/absent status.

Now, when I press submit, the information of only 1 student is inserted into the Attendance table. Usually, the last student. Which is not what I want – I want X number of rows inserted when I press submit, where X is equal to the number of students in the table.

How do I achieve this? Thank you for reading.