<?php
include 'confing.php';

$response = array();

$typeResult = $conn->query("SELECT DISTINCT vehicle_type FROM other");
$types = array();
while ($row = $typeResult->fetch_assoc()) {
    $types[] = $row['vehicle_type'];
}
$response['vehicle_type'] = $types;

$brandResult = $conn->query("SELECT DISTINCT vehicle_brand FROM other");
$brands = array();
while ($row = $brandResult->fetch_assoc()) {
    $brands[] = $row['vehicle_brand'];
}
$response['vehicle_brand'] = $brands;

$modelResult = $conn->query("SELECT DISTINCT vehicle_model FROM other");
$models = array();
while ($row = $modelResult->fetch_assoc()) {
    $models[] = $row['vehicle_model'];
}
$response['vehicle_model'] = $models;

$shareResult = $conn->query("SELECT DISTINCT share_location FROM other");
$shares = array();
while ($row = $shareResult->fetch_assoc()) {
    $shares[] = $row['share_location'];
}
$response['share_location'] = $shares;

$apartmentResult = $conn->query("SELECT DISTINCT apartment FROM other");
$apartments = array();
while ($row = $apartmentResult->fetch_assoc()) {
    $apartments[] = $row['apartment'];
}
$response['apartment'] = $apartments;

header('Content-Type: application/json');
echo json_encode($response);
?>
