<?php
include("dbconfig.php");

// Check if the delete form is submitted
if (isset($_POST['delete'])) {
    // Get the bill number from the form
    $billno = $_POST['bill_no'];

    // SQL query to update the `is_deleted` field to 0
    $updateQuery = "UPDATE `examination` SET `is_deleted` = 0 WHERE `BillNo` = '$billno'";

    // Run the query
    if (mysqli_query($db, $updateQuery)) {
        // If update is successful, redirect with success message
        echo "<script>alert('Examination record marked as deleted successfully.'); window.location.href='examination.php';</script>";
    } else {
        // If there is an error, show an error message and redirect
        echo "<script>alert('Error updating examination record.'); window.location.href='examination.php';</script>";
    }
}
?>
