prepare("SELECT id, name, code FROM projects WHERE name LIKE ? OR code LIKE ? LIMIT 5"); $stmt->execute(['%' . $q . '%', '%' . $q . '%']); foreach ($stmt->fetchAll() as $row) { $results[] = [ 'type' => 'Project', 'id' => $row['id'], 'label' => $row['name'] . ' (' . $row['code'] . ')', 'url' => 'project_detail.php?id=' . $row['id'] ]; } // Search Employees $stmt = $db->prepare("SELECT id, name, position FROM employees WHERE name LIKE ? OR first_name LIKE ? OR last_name LIKE ? LIMIT 5"); $stmt->execute(['%' . $q . '%', '%' . $q . '%', '%' . $q . '%']); foreach ($stmt->fetchAll() as $row) { $results[] = [ 'type' => 'Employee', 'id' => $row['id'], 'label' => $row['name'] . ' - ' . ($row['position'] ?? 'Staff'), 'url' => 'employee_detail.php?id=' . $row['id'] ]; } } catch (Exception $e) { // Silence error for now } echo json_encode($results);