test filtre 4/?

This commit is contained in:
Vincent TEISSIER 2024-06-04 16:39:51 +02:00
parent d9c01b0729
commit 3796662e08
3 changed files with 6 additions and 3 deletions
application
controllers
models
views/layout

@ -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();

@ -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);
}

@ -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 -->