ajout chansons

This commit is contained in:
2024-05-27 13:32:33 +02:00
parent 5693312077
commit aa05e82ca5
4 changed files with 49 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Chansons extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->model('model_music');
$this->load->helper('html');
$this->load->helper('url');
}
public function index(){
$chansons = $this->model_music->getChansons();
$this->load->view('layout/header');
$this->load->view('chansons_list',['chansons'=>$chansons]);
$this->load->view('layout/footer');
}
}

View File

@@ -27,4 +27,18 @@ class Model_music extends CI_Model {
);
return $query->result();
}
public function getChansons(){
$query = $this->db->query(
"SELECT song.name,song.id,album.year,album.name as albumName, artist.name as artistName, genre.name as genreName
FROM song
JOIN track ON track.songId = song.id
JOIN album ON album.id = track.albumId
JOIN artist ON album.artistid = artist.id
JOIN genre ON genre.id = album.genreid
ORDER BY album.year
"
);
return $query->result();
}
}

View File

@@ -0,0 +1,15 @@
<h5>Chansons list</h5>
<section class="list">
<?php
foreach($chansons as $chansons){
echo "<div><article>";
echo "<header class='short-text'>";
echo anchor("albums/view/{$chansons->id}","{$chansons->name}");
echo "</header>";
echo "<nav class='short-text'>Nom album: {$chansons->albumName}</nav>";
echo "<nav class='short-text'>Genre: {$chansons->genreName}</nav>";
echo "<footer class='short-text'>{$chansons->year} - {$chansons->artistName}</footer>
</article></div>";
}
?>
</section>

View File

@@ -20,6 +20,7 @@
<ul>
<li><?=anchor('albums','Albums');?></li>
<li><?=anchor('artistes','Artistes');?></li>
<li><?=anchor('chansons','Chansons');?></li>
<li><?=anchor('playlist','Playlist');?></li>
</ul>
</nav>