<?php
require 'db.php'; // your PDO connection

$search = $_GET['q'] ?? '';

$stmt = $pdo->prepare(
    "SELECT DISTINCT vendor
     FROM transactions
     WHERE vendor IS NOT NULL
       AND vendor != ''
       AND vendor LIKE ?
     ORDER BY vendor
     LIMIT 20"
);

$stmt->execute(["%$search%"]);
$vendors = $stmt->fetchAll(PDO::FETCH_COLUMN);

echo json_encode($vendors);