<?php
header('Content-Type: application/json');
include '../db.php'; // Include your database connection file

$driver_id = isset($_GET['driver_id']) ? $_GET['driver_id'] : '';

if (empty($driver_id)) {
    echo json_encode(['success' => false, 'message' => 'Driver ID is required']);
    exit;
}

$sql = "SELECT * FROM new_trip_booking WHERE driver = '$driver_id' AND status IN ('accepted', 'started', 'asigned')";
$result = $conn->query($sql);

$trips = [];
if ($result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        $trips[] = $row;
    }
}

echo json_encode($trips);

$conn->close();
?>
