<?php
require_once 'db/config.php';
$db = db();

try {
    $sql = "SELECT a.id, p.name as patient_name, a.start_time, a.patient_id, a.doctor_id
            FROM appointments a 
            JOIN patients p ON a.patient_id = p.id 
            WHERE a.status = 'Scheduled' 
            ORDER BY a.start_time ASC";
    $scheduled_appointments = $db->query($sql)->fetchAll();
    print_r($scheduled_appointments);
} catch (PDOException $e) {
    echo "Error: " . $e->getMessage();
}
