prepare("SELECT id, name, code, is_archived FROM projects WHERE name LIKE ? OR code LIKE ? LIMIT 5"); $stmt->execute(['%' . $q . '%', '%' . $q . '%']); foreach ($stmt->fetchAll() as $row) { $label = $row['name'] . ' (' . $row['code'] . ')'; if ($row['is_archived']) { $label .= ' [ARCHIVED]'; } $results[] = [ 'type' => 'Project', 'id' => $row['id'], 'label' => $label, '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);