"; + echo "
diff --git a/ci/application/controllers/Albums.php b/ci/application/controllers/Albums.php index 7ee8f12..9a7b883 100644 --- a/ci/application/controllers/Albums.php +++ b/ci/application/controllers/Albums.php @@ -13,12 +13,11 @@ class Albums extends CI_Controller { $this->load->view('albums_list',['albums'=>$albums]); $this->load->view('layout/footer'); } - public function view(){ - $albums = $this->model_music->getSongOfAlbum(); - $this->load->view('layout/header'); - $this->load->view('song_album_list',['musique'=>$albums]); - $this->load->view('layout/footer'); + public function view($album_id){ + $songs = $this->model_music->getSongOfAlbum($album_id); + $this->load->view('layout/header'); + $this->load->view('song_album_list',['songs'=>$songs]); + $this->load->view('layout/footer'); } - } diff --git a/ci/application/models/Model_music.php b/ci/application/models/Model_music.php index 5ebda24..2297c38 100644 --- a/ci/application/models/Model_music.php +++ b/ci/application/models/Model_music.php @@ -28,13 +28,14 @@ class Model_music extends CI_Model { return $query->result(); } - public function getSongOfAlbum(){ - $query = $this->db->query( - "SELECT artist.id, artist.name - FROM artist - Group by artist.id - " - ); - return $query->result(); + public function getSongOfAlbum($album_id){ + $query = $this->db->query( + "SELECT song.id, song.name + FROM song + INNER JOIN track ON song.id = track.songId + WHERE track.albumId = ?", + array($album_id) + ); + return $query->result(); } } diff --git a/ci/application/views/albums_list.php b/ci/application/views/albums_list.php index 77ec1ee..0fd49bb 100644 --- a/ci/application/views/albums_list.php +++ b/ci/application/views/albums_list.php @@ -4,7 +4,7 @@ foreach($albums as $album){ echo "