<?php
include('../include/auth.php'); // Ensure security
include('../include/head.php'); // DB connection is in head.php

if (isset($_GET['vehicle_type'])) {
    $vehicleType = intval($_GET['vehicle_type']);

    $stmt = $db2->prepare("SELECT id, name FROM availability_groups WHERE vehicle_type = ?");
    $stmt->bind_param("i", $vehicleType);
    $stmt->execute();
    $result = $stmt->get_result();

    while ($row = $result->fetch_assoc()) {
        echo '<option value="' . $row['id'] . '">' . htmlspecialchars($row['name']) . '</option>';
    }

    $stmt->close();
}
?>
