<?php
include 'includes/config.php';

$search = isset($_GET['term']) ? htmlspecialchars($_GET['term']) : '';

if ($search) {
    $stmt = $conn->prepare("SELECT name FROM products WHERE name LIKE :search AND business_id = :business_id LIMIT 10");
    $stmt->bindValue(':search', '%' . $search . '%', PDO::PARAM_STR);
    $stmt->bindValue(':business_id', 3, PDO::PARAM_INT); // Set the business_id to 3
    $stmt->execute();
    $results = $stmt->fetchAll(PDO::FETCH_COLUMN);

    echo json_encode($results);
}
?>
