36247-vm/search_patient.php
2025-11-25 08:26:31 +00:00

13 lines
438 B
PHP

<?php
require_once 'db/config.php';
if (isset($_GET['term'])) {
$term = $_GET['term'];
$pdo = db();
$stmt = $pdo->prepare('SELECT id, patient_id, patient_name FROM patients WHERE patient_name LIKE :term OR patient_id LIKE :term LIMIT 10');
$stmt->execute(['term' => '%' . $term . '%']);
$patients = $stmt->fetchAll(PDO::FETCH_ASSOC);
header('Content-Type: application/json');
echo json_encode($patients);
}
?>