<?php
include 'db.php';
$term = $_GET['term'] ?? '';
$term = trim($term);
if ($term === '') {
echo json_encode([]);
exit;
}
$stmt = $pdo->prepare("SELECT name FROM companies WHERE name LIKE ? LIMIT 10");
$stmt->execute(['%' . $term . '%']);
$results = $stmt->fetchAll(PDO::FETCH_COLUMN);
echo json_encode($results);