<?php
include('includes/dbconnection.php');

$result = $con->query("SELECT title, event_date FROM events");

$colors = ['#ffcc80', '#90caf9', '#a5d6a7', '#f48fb1']; // Different event colors
$events = [];
$index = 0;

while ($row = $result->fetch_assoc()) {
    $events[] = [
        'title' => $row['title'],
        'start' => $row['event_date'],
        'backgroundColor' => $colors[$index % count($colors)],
        'borderColor' => '#666'
    ];
    $index++;
}

echo json_encode($events);
?>