<?php
require_once 'config.php';
$q = $_GET['q'] ?? '';
if(strlen($q) < 2) { echo json_encode([]); exit; }
$stmt = $pdo->prepare("SELECT id, title_bn FROM courses WHERE status='published' AND title_bn LIKE ? LIMIT 8");
$stmt->execute(["%$q%"]);
echo json_encode($stmt->fetchAll());