File "search_suggest.php"

Full Path: /home/alphpwcp/previewstream.online/old/search_suggest.php
File size: 344 bytes
MIME-type: text/x-php
Charset: utf-8

<?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);