prepare("SELECT * FROM schedules s LEFT JOIN schedule_blocks sb ON s.day = sb.schedule_day LEFT JOIN blocks b ON sb.block_id = b.id WHERE s.day = :date"); $query->bindValue(":date", intval(strtotime($_GET['date']))); $result = $query->execute(); if ($result) { $row = $result->fetchArray(SQLITE3_ASSOC); echo(json_encode($row)); } } else if (isset($_POST['day']) && strtotime($_POST['day'])) { // add or update a single schedule } else { echo("{}"); } ?>