dealing with the checkbox and send to database

I have been using the code for sending the data into database when the checkbox is checked then it should send true to database. when unchecked and send then false should be shown.
in database I have used datatype enum p and a as its values and a is its default value.

<?php

if (isset($_POST['save'])) {
    $errors = []; // Initialize an empty errors array

    // Check if any attendance data was submitted
    if (!isset($_POST['attendance']) || !is_array($_POST['attendance']) || empty($_POST['attendance'])) {
        $errors[] = "No attendance data submitted. Please select student(s) and their status.";
    }

    // If no errors, proceed with processing attendance
    if (empty($errors)) {
        foreach ($_POST['attendance'] as $student_id => $status) {
            // Check if the checkbox is checked (present) or not (absent)
            $status = isset($status) ? 'p' : 'a'; // Present: 'p', Absent: 'a'
            $reason = isset($_POST['reason'][$student_id]) ? $_POST['reason'][$student_id] : 'Not Specified';

            // Prepare INSERT query with placeholders
            $sql = "INSERT INTO stds_attendance (student_id, status, reason) VALUES (?, ?, ?)";
            $stmt = mysqli_prepare($conn, $sql);

            if ($stmt) {
                mysqli_stmt_bind_param($stmt, 'sss', $student_id, $status, $reason);

                if (mysqli_stmt_execute($stmt)) {
                    echo "Attendance data for student $student_id saved successfully.<br>";
                } else {
                    $errors[] = "Error saving attendance data: " . mysqli_stmt_error($stmt);
                }

                mysqli_stmt_close($stmt);
            } else {
                $errors[] = "Error preparing statement: " . mysqli_error($conn);
            }
        }
    }

    // Display any accumulated errors
    if (!empty($errors)) {
        echo "<ul class='error-list'>";
        foreach ($errors as $error) {
            echo "<li>$error</li>";
        }
        echo "</ul>";
    }
}

?>