-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch_doctor.php
29 lines (27 loc) · 1011 Bytes
/
fetch_doctor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
$con = mysqli_connect("localhost", "root", "", "hmsdb");
if (!$con) {
die("Connection failed: " . mysqli_connect_error());
}
// Check if the doctor_id parameter is set
if (isset($_POST['doctor_id'])) {
$doctor_id = $_POST['doctor_id'];
// Query to retrieve the doctor's information based on the doctor_id
$query = "SELECT * FROM doctor WHERE doctor_id = $doctor_id;";
$result = mysqli_query($con, $query);
if ($result) {
$data = mysqli_fetch_assoc($result);
if ($data) {
// Return the doctor's information as JSON response
echo json_encode(array('status' => 'success', 'data' => $data));
} else {
echo json_encode(array('status' => 'error', 'message' => 'Doctor not found.'));
}
} else {
echo json_encode(array('status' => 'error', 'message' => 'Query failed.'));
}
} else {
echo json_encode(array('status' => 'error', 'message' => 'Missing doctor_id parameter.'));
}
mysqli_close($con);
?>