netv-mam/schedule.php

25 lines
669 B
PHP
Raw Permalink Normal View History

2024-09-10 16:44:22 -04:00
<?php
$db = new SQLite3('netv-mam.sqlite');
if (isset($_GET['date']) && $_GET['date'] !== "") {
// get info about single day's schedule
2024-09-22 12:41:58 -04:00
$query = $db->prepare("SELECT * FROM schedules s
2024-09-24 14:35:32 -04:00
LEFT JOIN schedule_blocks sb ON s.day = sb.schedule_day
2024-09-22 12:41:58 -04:00
LEFT JOIN blocks b ON sb.block_id = b.id
2024-09-24 14:14:10 -04:00
WHERE s.day = :date");
2024-09-22 12:41:58 -04:00
$query->bindValue(":date", intval(strtotime($_GET['date'])));
2024-09-10 16:44:22 -04:00
$result = $query->execute();
if ($result) {
$row = $result->fetchArray(SQLITE3_ASSOC);
echo(json_encode($row));
}
2024-09-24 14:14:10 -04:00
} else if (isset($_POST['day']) && strtotime($_POST['day'])) {
2024-09-24 14:35:32 -04:00
// add or update a single schedule
2024-09-10 16:44:22 -04:00
} else {
echo("{}");
}
?>