ajout tout les morceau d'un artiste
This commit is contained in:
parent
831f05ca6b
commit
adcb08be5d
@ -23,7 +23,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
| a PHP script and you can easily do that on your own.
|
| a PHP script and you can easily do that on your own.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
$config['base_url'] = '/~brigitte/SAEWEB2.2/ci/';
|
$config['base_url'] = '/~gallego/SAEWEB2.2/ci/';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
@ -9,8 +9,9 @@ class artistes extends CI_Controller {
|
|||||||
}
|
}
|
||||||
public function index(){
|
public function index(){
|
||||||
$artistes = $this->model_music->getArtists();
|
$artistes = $this->model_music->getArtists();
|
||||||
|
$playlists = $this->model_music->getPlaylist();
|
||||||
$this->load->view('layout/header');
|
$this->load->view('layout/header');
|
||||||
$this->load->view('artistes_list',['artistes'=>$artistes]);
|
$this->load->view('artistes_list',['artistes'=>$artistes, 'playlists' => $playlists]);
|
||||||
$this->load->view('layout/footer');
|
$this->load->view('layout/footer');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,4 +33,12 @@ class artistes extends CI_Controller {
|
|||||||
redirect('playlist');
|
redirect('playlist');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addSongOfArtistToPlaylist(){
|
||||||
|
$playlistId = $this->input->post('playlist');
|
||||||
|
$artistId = $this->input->post('artistId');
|
||||||
|
$this->model_music->addAllSongsOfArtistInPlaylist($artistId, $playlistId);
|
||||||
|
redirect('artistes');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -107,4 +107,25 @@ class Model_music extends CI_Model {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addAllSongsOfArtistInPlaylist($artistId, $playlistId){
|
||||||
|
// Récupérer toutes les chansons de l'artiste spécifié
|
||||||
|
$query = $this->db->query(
|
||||||
|
"SELECT song.name
|
||||||
|
FROM song, track, album
|
||||||
|
WHERE song.id = track.songId
|
||||||
|
AND track.albumId = album.id
|
||||||
|
AND album.artistId = ?",
|
||||||
|
array($artistId)
|
||||||
|
);
|
||||||
|
|
||||||
|
$songs = $query->result();
|
||||||
|
|
||||||
|
// Ajouter chaque chanson dans la playlist spécifiée
|
||||||
|
foreach ($songs as $song) {
|
||||||
|
$this->db->query(
|
||||||
|
"INSERT INTO SongPlaylist (id, name) VALUES (?, ?)",
|
||||||
|
array($playlistId, $song->name)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
|
|
||||||
<section class="artiste">
|
<section class="artiste">
|
||||||
<?php
|
<?php
|
||||||
foreach($artistes as $artiste){
|
foreach($artistes as $artiste){
|
||||||
//echo "<div><article>";
|
echo "<form action='" . base_url("index.php/artistes/addSongOfArtistToPlaylist") . "' method='post'>";
|
||||||
//echo "<header class='short-text'>";
|
echo anchor("artistes/view/{$artiste->id}", "{$artiste->name}");
|
||||||
echo anchor("artistes/view/{$artiste->id}","{$artiste->name}");
|
echo "<select name='playlist'>";
|
||||||
echo "<br>";
|
foreach ($playlists as $playlist) {
|
||||||
echo "</header>";
|
echo "<option value='{$playlist->id}'>{$playlist->name}</option>";
|
||||||
//echo "<footer class='short-text'>{$artistes->year} - {$artistes->artistName}</footer>
|
}
|
||||||
//</article></div>";
|
echo "</select>";
|
||||||
|
echo "<input type='hidden' name='artistId' value='{$artiste->id}' />"; // Utilisez l'identifiant de l'artiste ici
|
||||||
|
echo "<button type='submit' class='add-to-playlist'>+</button>";
|
||||||
|
echo "</form>";
|
||||||
|
echo "<br>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</section>
|
</section>
|
Loading…
Reference in New Issue
Block a user