<?php require_once "../classes/Database.php"; require_once "../classes/Screening.php"; require_once "../classes/Movie.php"; require_once "../classes/Cinema.php"; if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["movie"])) { $movieId = $_POST["movie"]; $cinemaId = $_POST["cinema"]; $dateFormatted = str_replace("T", " ", $_POST["date"]); $db = DATABASE::getInstance(); $mysqli = $db->getConnection(); $movie = new Movie($mysqli); $movie->findMovieById($movieId); $cinema = new Cinema($mysqli); $cinema->findCinemaById($cinemaId); $screening = new Screening($mysqli); $screening->setMovie($movie); $screening->setCinema($cinema); $screening->setDate($dateFormatted); $screening->addToDatabase(); header("location: adminPanel.php"); }
public function getCinemaScreenings($id) { $sqlQuery = "SELECT id, cinema_id, movie_id, date FROM screenings WHERE date > NOW() AND cinema_id = {$id} ORDER BY date "; $conn = parent::getConnection(); $result = $conn->query($sqlQuery); if ($result->num_rows > 0) { while (list($id, $cinemaId, $movieId, $date) = $result->fetch_array(MYSQLI_NUM)) { $movie = new Movie($conn); $movie->findMovieById($movieId); $cinema = new Cinema($conn); $cinema->findCinemaById($cinemaId); $screening = new Screening($conn); $screening->setMovie($movie); $screening->setCinema($cinema); $screening->setDate($date); $screening->setId($id); $this->setArrayWithCinemaScreenings($screening); } } }