delete song
This commit is contained in:
parent
9d492207b0
commit
8b0ec23975
@ -24,9 +24,15 @@ class Playlist extends CI_Controller {
|
||||
|
||||
public function SongPlaylist($playlist_id){
|
||||
$songPlaylists = $this->model_music->getSongOfPlaylist($playlist_id);
|
||||
//$this->load->view('layout/header_album');
|
||||
$this->load->view('song_playlist', ['songPlaylists' => $songPlaylists]);
|
||||
//$this->load->view('layout/footer_album');
|
||||
$playlists = $this->model_music->getPlaylist(); // Récupère toutes les playlists
|
||||
$id_playlist = null; // Initialise $id_playlist à null
|
||||
foreach ($playlists as $playlist_item) {
|
||||
if ($playlist_item->id == $playlist_id) {
|
||||
$id_playlist = $playlist_item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->load->view('song_playlist', ['songPlaylists' => $songPlaylists, 'id_playlist' => $id_playlist]);
|
||||
}
|
||||
|
||||
public function delete($playlist_id) {
|
||||
@ -34,6 +40,11 @@ class Playlist extends CI_Controller {
|
||||
redirect('playlist');
|
||||
}
|
||||
|
||||
public function deleteSong($id_playlist, $Song_name){
|
||||
$deleteSong = $this->model_music->delete_Song($id_playlist, $Song_name);
|
||||
redirect("playlist/SongPlaylist/$id_playlist");
|
||||
}
|
||||
|
||||
public function MenuCreate() {
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('create_playlist');
|
||||
|
@ -49,8 +49,14 @@ class Model_music extends CI_Model {
|
||||
);
|
||||
}
|
||||
|
||||
public function delete_Song($playlist_id,$Song_name){
|
||||
$this->db->query(
|
||||
"DELETE FROM SongPlaylist Where id = ? AND name LIKE ?",
|
||||
array($playlist_id, $Song_name)
|
||||
);
|
||||
}
|
||||
|
||||
public function createPlaylist($name_playlist){
|
||||
$playlist_id = mt_rand(1, 10);
|
||||
$name_playlist_escaped = $this->db->escape($name_playlist);
|
||||
$query = $this->db->query(
|
||||
"INSERT INTO playlist (name) VALUES ($name_playlist_escaped);
|
||||
|
@ -4,7 +4,10 @@
|
||||
foreach($songPlaylists as $songPlaylist){
|
||||
echo "<div><article>";
|
||||
echo "<header class='short-text'>";
|
||||
echo "<form action='" . base_url("index.php/Playlist/deleteSong/{$id_playlist -> id}/{$songPlaylist-> name}") . "' method='post'>";
|
||||
echo "{$songPlaylist->name}";
|
||||
echo "<button type='submit' class='delete-button'>Delete</button>";
|
||||
echo "</form>";
|
||||
echo "<br>";
|
||||
echo "</header>";
|
||||
echo "</article></div>";
|
||||
|
Loading…
Reference in New Issue
Block a user