-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevents.php
More file actions
31 lines (25 loc) · 865 Bytes
/
events.php
File metadata and controls
31 lines (25 loc) · 865 Bytes
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
// Database connection script
require_once('db.php');
try {
// Fetching events from the database
$sql = "SELECT * FROM events";
$stmt = $db->query($sql);
$events = $stmt->fetchAll(PDO::FETCH_ASSOC);
$calendar_events = [];
foreach ($events as $event) {
$calendar_event = [
'title' => $event['name'],
'start' => $event['event_date'] . 'T' . $event['event_time'], // Combine date and time
'end' => $event['event_date'] . 'T' . $event['event_time'],
'venue' => $event['venue'],
'organizing_party' => $event['organizing_party']
];
$calendar_events[] = $calendar_event;
}
echo json_encode($calendar_events);
} catch (PDOException $e) {
// To handle database connection or query errors
echo "Error: " . $e->getMessage();
}
?>