prepare("
SELECT Start_Date, End_Date
FROM schedule_course_for_group
WHERE Program_ID = ? AND Group_ID = ? AND Course_ID = ?
");
$stmt->bind_param("iii", $Program_ID, $Group_ID, $Course_ID);
$stmt->execute();
$result = $stmt->get_result();
// Build array of all taken dates in the range
while ($row = $result->fetch_assoc()) {
$start = $row['Start_Date'];
$end = $row['End_Date'];
$period = new DatePeriod(
new DateTime($start),
new DateInterval('P1D'),
(new DateTime($end))->modify('+1 day')
);
foreach ($period as $dt) {
$dates[] = $dt->format("Y-m-d");
}
}
$stmt->close();
}
echo json_encode($dates);
?>