From 3796662e086f3c6232f58be221b2a86035d8ab0e Mon Sep 17 00:00:00 2001 From: Vince <vi.teissier@gmail.com> Date: Tue, 4 Jun 2024 16:39:51 +0200 Subject: [PATCH] test filtre 4/? --- application/controllers/Albums.php | 2 +- application/models/Model_music.php | 6 +++++- application/views/layout/getter.php | 1 - 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/application/controllers/Albums.php b/application/controllers/Albums.php index 602c9a9..7360c40 100644 --- a/application/controllers/Albums.php +++ b/application/controllers/Albums.php @@ -15,7 +15,7 @@ class Albums extends CI_Controller { $artist = $this->input->get('artist'); $query = $this->input->get('query'); - $albums = $this->model_music->getAlbums($genre, $order, $artist); + $albums = $this->model_music->getAlbums($genre, $order, $artist, $query); $genres = $this->model_music->researchtype(); $artists = $this->model_music->nameArtist(); diff --git a/application/models/Model_music.php b/application/models/Model_music.php index 93e7c40..151c79f 100644 --- a/application/models/Model_music.php +++ b/application/models/Model_music.php @@ -5,7 +5,7 @@ class Model_music extends CI_Model { $this->load->database(); } - public function getAlbums($genre = '', $order = 'asc', $artist = '') { + public function getAlbums($genre = '', $order = 'asc', $artist = '', $query = '') { $this->db->select('album.name, album.id, year, artist.name as artistName, genre.name as genreName, jpeg'); $this->db->from('album'); $this->db->join('artist', 'album.artistid = artist.id'); @@ -16,6 +16,10 @@ class Model_music extends CI_Model { $this->db->where('genre.name', $genre); } + if(!empty($query)){ + $this->db->where('album.name', $query); + } + if(!empty($artist)){ $this->db->where('artist.name', $artist); } diff --git a/application/views/layout/getter.php b/application/views/layout/getter.php index 75aeaa1..e79f9c0 100644 --- a/application/views/layout/getter.php +++ b/application/views/layout/getter.php @@ -2,7 +2,6 @@ <!-- Champ de recherche --> <form method="GET" action=""> <input type="text" name="query" placeholder="Rechercher..." value="<?= isset($_GET['query']) ? $_GET['query'] : '' ?>"> - <button type="submit">Rechercher</button> </form> <!-- Bouton pour afficher/masquer les filtres -->