<?php
// Include the database connection file
include 'db.php';

header('Content-Type: application/json');

$userId = $_GET['user_id'];

if (isset($userId)) {
    $sql = "SELECT * FROM new_trip_booking WHERE user_id = ? order by id DESC limit 10 ";
    $stmt = $conn->prepare($sql);
    $stmt->bind_param("i", $userId);
    $stmt->execute();

    $result = $stmt->get_result();
    $bookings = $result->fetch_all(MYSQLI_ASSOC);

    echo json_encode($bookings);
} else {
    echo json_encode(['error' => 'User ID not provided']);
}
?>
