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

include 'db.php';

// SQL query to fetch vehicle details
$sql = "SELECT *, vehicle_type, price, capacity FROM vehicle_prices";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    $vehicles = [];
    while ($row = $result->fetch_assoc()) {
        $vehicles[$row['vehicle_type']] = [
            'price' => $row['price'],
            'capacity' => $row['capacity'],
            'minimum' => $row['minimum']
        ];
    }
    echo json_encode($vehicles);
} else {
    echo json_encode([]);
}

$conn->close();
?>
