diff --git a/src/WebApp/application/views/best_films.php b/src/WebApp/application/views/best_films.php index d0cc77fa515a5961a75eb0f3495d2fa728b52612..6eaef3f6ab8d0fc986d76739cbea0a909012d20c 100644 --- a/src/WebApp/application/views/best_films.php +++ b/src/WebApp/application/views/best_films.php @@ -7,7 +7,6 @@ */ defined('BASEPATH') OR exit('No direct script access allowed'); include('getMovie.php'); -$array=getBestMovieArray(); ?><!DOCTYPE html> <html> @@ -101,6 +100,40 @@ $array=getBestMovieArray(); <div id="class" class="row align-items-center no-gutters mb-4 mb-lg-5"> <div class="featured-text text-center text-lg-left"> <h1>Les films les mieux notés</h1> + + <center><form method="POST" action="best_films" name="formulaire"> + <div class="form-group"> + <!--<input type = submit class="btn btn-primary js-scroll-trigger " href="#projects" value = "Cliquez ici pour générer un film2 aléatoire">--> + <label for="film"><a class="btn btn-primary js-scroll-trigger" href="#projects" onclick="document.formulaire.submit();return false;" type="submit">Cliquez ici pour actualiser le classement</a> + <br /><br /><select name="genre" class="form-control flex-fill mr-0 mr-sm-2 mb-3 mb-sm-0" id="genre" style="text-align:center"> + <option value="">Tous les genres</option> + <option value=18>Action</option> + <option value=12>Aventure</option> + <option value=35>Comédie</option> + <option value=18>Drame</option> + <option value=27>Horreur</option> + <option value=9648>Mystère</option> + <option value=878>Science-Fiction</option> + </select> + <br/> + + </label> + </div> + </form></center> + + <?php + if (isset($_POST["genre"])) + { + echo $_POST["genre"]; + $array=getBestMovieArray(($_POST["genre"])); + } + else + { + echo "test"; + $array=getBestMovieArray(""); + } + ?> + <div> <table class="table borderless"> <tbody> diff --git a/src/WebApp/application/views/getMovie.php b/src/WebApp/application/views/getMovie.php index a038cac75154dc96ad98074b0225f4166c31629d..47bcd7209d91e6711515893ed9b8c6fabbecaf0b 100644 --- a/src/WebApp/application/views/getMovie.php +++ b/src/WebApp/application/views/getMovie.php @@ -48,9 +48,9 @@ function getMovieRecommendationArray($id) return $movie_array; } -function getBestMovieArray() +function getBestMovieArray($genre) { - $tmdb_url='https://api.themoviedb.org/3/discover/movie?api_key=7ac6810245f15284418f2a15b9b22225&language=fr-FR&sort_by=vote_average.desc&vote_count.gte=10000'; + $tmdb_url='https://api.themoviedb.org/3/discover/movie?api_key=7ac6810245f15284418f2a15b9b22225&with_genres=' . $genre . 'language=fr-FR&sort_by=vote_average.desc&vote_count.gte=10000'; $movie_json = file_get_contents($tmdb_url); $movie_array = json_decode($movie_json, true);