-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetMeetingDetails.php
31 lines (26 loc) · 1016 Bytes
/
GetMeetingDetails.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
<?php
include "Conx.php";
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Content-Type, Authorization');
header('Content-Type: application/json');
if ($_SERVER['REQUEST_METHOD'] == 'GET' && isset($_GET['id'])) {
$id = intval($_GET['id']);
$query = "SELECT m.id, m.event_title, m.start_date, m.start_time, m.end_time, m.location, u.name AS farmer_name
FROM meetings m
JOIN users u ON m.farmer_id = u.id
WHERE m.id = ?";
$stmt = $conn->prepare($query);
$stmt->bind_param("i", $id);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
$meeting = $result->fetch_assoc();
echo json_encode(['success' => true, 'meeting' => $meeting]);
} else {
echo json_encode(['success' => false, 'message' => 'Meeting not found']);
}
} else {
echo json_encode(['success' => false, 'message' => 'Invalid request']);
}
$conn->close();
?>