-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_appointments.php
39 lines (33 loc) · 1.38 KB
/
get_appointments.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
30
31
32
33
34
35
36
37
38
39
<?php
require_once 'db_config.php'; // Σύνδεση με τη βάση δεδομένων
if (isset($_POST['patient_email'])) {
$patient_email = $_POST['patient_email'];
// SQL ερώτηση για ανάκτηση ραντεβού συγκεκριμένου ασθενούς μέσω του πίνακα books
$stmt_appointments = $conn->prepare("
SELECT r.a_date, r.a_time, r.a_desc, r.a_state, d.D_Name AS doctor_first_name, d.D_Surname AS doctor_last_name
FROM rantevou r
JOIN books b ON r.id_appointment = b.id_appointment
JOIN asthenis a ON b.AT = a.AT
JOIN xristis x ON a.AT = x.AT
JOIN iatros d ON r.a_doc = d.D_id
WHERE x.Email = ?
");
$stmt_appointments->bind_param("s", $patient_email);
$stmt_appointments->execute();
$result_appointments = $stmt_appointments->get_result();
$appointments = [];
while ($row = $result_appointments->fetch_assoc()) {
$appointments[] = [
'a_date' => $row['a_date'],
'a_time' => $row['a_time'],
'a_desc' => $row['a_desc'],
'a_state' => $row['a_state'],
'a_doc' => $row['doctor_first_name'] . ' ' . $row['doctor_last_name']
];
}
$stmt_appointments->close();
$conn->close();
// Επιστροφή αποτελεσμάτων ως JSON
echo json_encode($appointments);
}
?>