Files
2026-09-16 23:20:08 +07:00

21 lines
725 B
PHP

<?php
require_once '../includes/db.php';
require_once '../includes/api_helper.php';
try {
// Fetch unique brands
$stmtBrands = $pdo->query("SELECT DISTINCT brand FROM vehicles WHERE brand IS NOT NULL AND brand != '' ORDER BY brand");
$brands = $stmtBrands->fetchAll(PDO::FETCH_COLUMN);
// Fetch unique models
$stmtModels = $pdo->query("SELECT DISTINCT model FROM vehicles WHERE model IS NOT NULL AND model != '' ORDER BY model");
$models = $stmtModels->fetchAll(PDO::FETCH_COLUMN);
echo jsonResponse(true, 'Suggestions loaded', [
'brands' => $brands,
'models' => $models
]);
} catch (PDOException $e) {
echo jsonResponse(false, 'Database error: ' . $e->getMessage());
}