Viewing file: chart-script.php (1.23 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include('conn.php');
// Query to count rejected appointments
$rejectedQuery = "SELECT COUNT(*) AS numRejected FROM appointments WHERE status = 'Rejected'";
$resultRejected = mysqli_query($con, $rejectedQuery);
$rowRejected = mysqli_fetch_assoc($resultRejected);
$numRejected = $rowRejected['numRejected'];
// Query to count pending appointments
$pendingQuery = "SELECT COUNT(*) AS numPending FROM appointments WHERE status = 'Pending'";
$resultPending = mysqli_query($con, $pendingQuery);
$rowPending = mysqli_fetch_assoc($resultPending);
$numPending = $rowPending['numPending'];
// Query to count approved appointments
$approvedQuery = "SELECT COUNT(*) AS numApproved FROM appointments WHERE status = 'Approved'";
$resultApproved = mysqli_query($con, $approvedQuery);
$rowApproved = mysqli_fetch_assoc($resultApproved);
$numApproved = $rowApproved['numApproved'];
// Store count values in an associative array
$countData = array(
'numRejected' => $numRejected,
'numPending' => $numPending,
'numApproved' => $numApproved
);
// Send count values as JSON response
header('Content-Type: application/json');
echo json_encode($countData);
// Close the database connection
mysqli_close($con);
?>
|