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

// Fetch sessions
$sql = "SELECT id, session_name FROM school_sessions ORDER BY start_date DESC";
$result = $con->query($sql);

$sessions = array();
if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
        $sessions[] = $row;
    }
}

echo json_encode($sessions);
$con->close();
?>