Test details artiste 1/?
This commit is contained in:
		@@ -29,5 +29,20 @@ class Artistes extends CI_Controller {
 | 
			
		||||
        $this->load->view('artists_list', $data);
 | 
			
		||||
        $this->load->view('layout/footer');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function view($artistId) {
 | 
			
		||||
        $artistData = $this->model_music->getArtistDetails($artistId);
 | 
			
		||||
 | 
			
		||||
        $is_logged_in = $this->session->userdata('logged_in');
 | 
			
		||||
        $data = array(
 | 
			
		||||
            'artist' => $artistData['artist'],
 | 
			
		||||
            'albums' => $artistData['albums'],
 | 
			
		||||
            'is_logged_in' => $is_logged_in
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        $this->load->view('layout/header', $data);
 | 
			
		||||
        $this->load->view('artist_details', $data);
 | 
			
		||||
        $this->load->view('layout/footer');
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -123,6 +123,26 @@ class Model_music extends CI_Model {
 | 
			
		||||
    
 | 
			
		||||
        return array('album' => $albumDetails, 'songs' => $songs);
 | 
			
		||||
    }
 | 
			
		||||
    public function getArtistDetails($artistId) {
 | 
			
		||||
        // Get artist info
 | 
			
		||||
        $this->db->select('artist.name as artistName, artist.id, genre.name as genreName, artist.jpeg');
 | 
			
		||||
        $this->db->from('artist');
 | 
			
		||||
        $this->db->join('album', 'album.artistid = artist.id');
 | 
			
		||||
        $this->db->join('genre', 'genre.id = album.genreid');
 | 
			
		||||
        $this->db->where('artist.id', $artistId);
 | 
			
		||||
        $artistQuery = $this->db->get();
 | 
			
		||||
        $artistDetails = $artistQuery->row();
 | 
			
		||||
    
 | 
			
		||||
        // Get artist's albums
 | 
			
		||||
        $this->db->select('album.name as albumName, album.id as albumId, album.year');
 | 
			
		||||
        $this->db->from('album');
 | 
			
		||||
        $this->db->where('album.artistid', $artistId);
 | 
			
		||||
        $albumsQuery = $this->db->get();
 | 
			
		||||
        $albums = $albumsQuery->result();
 | 
			
		||||
    
 | 
			
		||||
        return array('artist' => $artistDetails, 'albums' => $albums);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										18
									
								
								application/views/artist_details.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								application/views/artist_details.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html>
 | 
			
		||||
<head>
 | 
			
		||||
    <title><?= $artist->artistName ?> - Details</title>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
    <h1><?= $artist->artistName ?></h1>
 | 
			
		||||
    <p><strong>Genre:</strong> <?= $artist->genreName ?></p>
 | 
			
		||||
    <img src="data:image/jpeg;base64,<?= base64_encode($artist->jpeg) ?>" alt="<?= $artist->artistName ?> Photo">
 | 
			
		||||
 | 
			
		||||
    <h2>Albums</h2>
 | 
			
		||||
    <ul>
 | 
			
		||||
        <?php foreach ($albums as $album): ?>
 | 
			
		||||
            <li><?= anchor("albums/view/{$album->albumId}", $album->albumName) ?> (<?= $album->year ?>)</li>
 | 
			
		||||
        <?php endforeach; ?>
 | 
			
		||||
    </ul>
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
		Reference in New Issue
	
	Block a user