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

echo "<h2>Patient Queue (Latest 5)</h2>";
$stmt = $pdo->query("SELECT * FROM patient_queue ORDER BY id DESC LIMIT 5");
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($rows) {
    echo "<table border='1'><tr>";
    foreach (array_keys($rows[0]) as $k) echo "<th>$k</th>";
    echo "</tr>";
    foreach ($rows as $row) {
        echo "<tr>";
        foreach ($row as $v) echo "<td>$v</td>";
        echo "</tr>";
    }
    echo "</table>";
} else {
    echo "No records in patient_queue.<br>";
}

echo "<h2>Visits (Latest 5)</h2>";
$stmt = $pdo->query("SELECT id, patient_id, doctor_id, created_at FROM visits ORDER BY id DESC LIMIT 5");
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($rows) {
    echo "<table border='1'><tr>";
    foreach (array_keys($rows[0]) as $k) echo "<th>$k</th>";
    echo "</tr>";
    foreach ($rows as $row) {
        echo "<tr>";
        foreach ($row as $v) echo "<td>$v</td>";
        echo "</tr>";
    }
    echo "</table>";
} else {
    echo "No records in visits.<br>";
}
