barre de recherche

This commit is contained in:
Wilfried BRIGITTE 2024-06-10 18:45:37 +02:00
parent a1b797a1c5
commit ffd3f5dd39
2 changed files with 16 additions and 15 deletions

View File

@ -9,18 +9,9 @@ class Albums extends CI_Controller {
} }
public function index(){ public function index(){
$selectedGenre = '0'; // Valeur par défaut pour le genre si aucun n'est sélectionné $genre = $this->model_music->getGenre();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if(isset($_POST['Genre'])){
$selectedGenre = $_POST['Genre'];
}
}
$albums = $this->model_music->getAlbums($selectedGenre);
$playlists = $this->model_music->getPlaylist();
$this->load->view('layout/header'); $this->load->view('layout/header');
$this->load->view('albums_list', ['albums' => $albums, 'playlists' => $playlists]); $this->load->view('GenreFilter',['genre'=>$genre]);
$this->load->view('layout/footer');
$selectedGenre = '0'; $selectedGenre = '0';
$search = ''; $search = '';
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
@ -33,8 +24,15 @@ class Albums extends CI_Controller {
$search = $_POST['recherche']; $search = $_POST['recherche'];
} }
} }
$playlists = $this->model_music->getPlaylist();
$albums = $this->model_music->searchAlbums($search, $selectedGenre);
$this->load->view('albums_list', ['albums' => $albums, 'playlists' => $playlists]);
$this->load->view('layout/footer');
} }
public function view($album_id){ public function view($album_id){
$songs = $this->model_music->getSongOfAlbum($album_id); $songs = $this->model_music->getSongOfAlbum($album_id);
if (empty($songs)) { if (empty($songs)) {

View File

@ -1,5 +1,8 @@
<form method="post" action="albums"> <form method="post" action="albums">
<?php <?php
echo "<br>";
echo "<br>";
echo "<br>";
echo "<select id='GenreId' name='Genre'>"; echo "<select id='GenreId' name='Genre'>";
echo "<option value='0'>Select genre</option>"; echo "<option value='0'>Select genre</option>";
foreach($genre as $genre) { foreach($genre as $genre) {