function displayAllMovies() { $moviesDAO = new MoviesDAO(MaBD::getInstance()); $movies = $moviesDAO->getAll(); foreach ($movies as $movie) { displayMovie($movie); } }
$file = fopen($filename, 'a+'); $fileput = $movies['name'] . "," . $movies['year'] . "\r\n"; fputs($file, $fileput); fclose($file); } //saveMovie($movies); echo "<h1>Movie Ratings Database</h1>"; echo "Movies in database: " . count($movies) . "<br>"; $kidsMovieCount = 0; $restrictedMovieCount = 0; $recommendedMovieCount = 0; foreach ($movies as $k => $v) { if ($v['rating'] == "G") { echo $v['name'] . " is a kids Movie." . '<br>'; $kidsMovieCount++; } else { if ($v['rating'] == "PG") { saveMovie($movies); displayMovie($v['name']); $recommendedMovieCount++; } else { if ($v['rating'] == "R") { echo $v['name'] . " is a Restricted Movie." . '<br>'; $restrictedMovieCount++; } } } } $stringfile = "movie_counts.txt"; $data = "Children movies :" . $kidsMovieCount . "\n" . "Restricted movies :" . $restrictedMovieCount . "\n" . "Recommended movies : " . $recommendedMovieCount . "\n"; file_put_contents($stringfile, $data, FILE_APPEND);
$file = fopen($filename, 'a+'); $fileput = $movie['name'] . "," . $movie['year'] . "\r\n"; fputs($file, $fileput); fclose($file); } //saveMovie($movies); echo "<h1>Movie Ratings Database</h1>"; echo "Movies in database: " . count($movies) . "<br>"; $kidsMovieCount = 0; $restrictedMovieCount = 0; $recommendedMovieCount = 0; foreach ($movies as $k => $v) { if ($v['rating'] == "G") { echo $v['name'] . " is a kids Movie." . '<br>'; $kidsMovieCount++; } else { if ($v['rating'] == "PG") { saveMovie($v); displayMovie($v); $recommendedMovieCount++; } else { if ($v['rating'] == "R") { echo $v['name'] . " is a Restricted Movie." . '<br>'; $restrictedMovieCount++; } } } } $stringfile = "movie_counts.txt"; $data = "Children movies :" . $kidsMovieCount . "\n" . "Restricted movies :" . $restrictedMovieCount . "\n" . "Recommended movies : " . $recommendedMovieCount . "\n"; file_put_contents($stringfile, $data);
<?php displayHeader(); displayMenu(); if (isset($_GET['error'])) { displayError($_GET['error']); } if (isset($_GET["page"])) { $p = $_GET["page"]; if ($p == 'movie') { if (isset($_GET["id"]) && !empty($_GET["id"])) { displayMovie($_GET["id"]); } else { displayErrorId(); } } else { if ($p == 'admin') { displayAdmin(); } else { if ($p == 'edit') { if (isset($_GET["id"]) && !empty($_GET["id"])) { displayEditMovie($_GET["id"]); } else { if (isset($_GET["login"]) && !empty($_GET["login"])) { displayEditUser($_GET["login"]); } else { displayErrorId(); } } } else { if ($p == 'insert') {