diff --git a/showtimes/includes/loadFilms.php b/showtimes/includes/loadFilms.php new file mode 100644 index 0000000..62315be --- /dev/null +++ b/showtimes/includes/loadFilms.php @@ -0,0 +1,68 @@ +load(); + } + + //Methods: + //Returns an array with the titles of the available movies. + public function getFilms(){ + return $this->films; + } + + //Returns an array with the descriptions of the available movies. + public function getDescription(){ + $this->loadDescriptions(); + return $this->descriptions; + } + + //Load the list of tittles of the movies. + private function load(){ + $this->films = array(); + $tittles = new Film_DAO("complucine"); + $reply = $tittles->tittleFilmData(); + + if($reply && $reply->num_rows>0){ + $i = 0; + while ($row = $reply->fetch_assoc()){ + foreach($row as $key => $value){ + $this->films[$i] = $value; + } + $i++; + } + } + + $reply->free(); + } + + private function loadDescriptions(){ + $this->descriptions = array(); + $desc = new Film_DAO("complucine"); + $reply = $desc->descriptionFilmData(); + + if($reply && $reply->num_rows>0){ + $i = 0; + while ($row = $reply->fetch_assoc()){ + foreach($row as $key => $value){ + $this->descriptions[$i] = $value; + } + $i++; + } + } + + $reply->free(); + } + } +?> \ No newline at end of file diff --git a/showtimes/index.php b/showtimes/index.php index fe7c6c3..7dc7eef 100644 --- a/showtimes/index.php +++ b/showtimes/index.php @@ -2,23 +2,17 @@ get_prefix(); - // BORRAR CUANDO TENGAMOS BBDD: - $films = array( - "iron_man", - "iron_man_2", - "iron_man_3", - "capitan_america_el_primer_vengador", - "capitan_america_el_soldado_de_invierno", - "capitan_america_civil_war", - "marvel_avengers", - "avengers_age_of_ultron", - "avengers_inifinity_war", - "avengers_end_game" - ); + //List of the tittles and descriptions of the movies: + require_once('includes/loadFilms.php'); + $loadFilms = new loadFilms(); + $films = $loadFilms->getFilms(); + $descriptions = $loadFilms->getDescription(); + ?>