

<?php 
include_once("database.php");

function fetchData($connection, $sqlQuery) {
    $result = mysqli_query($connection, $sqlQuery);
    
    if (!$result) {
        die('Error: ' . mysqli_error($connection));
    }

    $data = array();

    // Use mysqli_fetch_assoc() instead of mysqli_fetch_all()
    while ($row = mysqli_fetch_assoc($result)) {
        $data[] = $row;
    }

    mysqli_free_result($result);

    return $data;
}
 







//Appointments
$sql = "SELECT * FROM appointments";
$appointments = fetchData($conn, $sql);
//Appointments
$sql = "SELECT * FROM users";
$users = fetchData($conn, $sql);


