mirror of
https://grond.iut-fbleau.fr/stiti/SAE_2.02
synced 2024-11-12 22:01:41 +01:00
Ajout d'un modele et d'un controlleur pour récupérer les covers d'album pour l'accueil
This commit is contained in:
parent
f72c867d9a
commit
ee34a0131a
@ -1,10 +1,16 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Home extends CI_Controller {
|
||||
|
||||
public function index() {
|
||||
// Charger la vue de la page d'accueil
|
||||
$this->load->view('accueil');
|
||||
}
|
||||
|
||||
public function index() {
|
||||
// Charger le modèle
|
||||
$this->load->model('Cover_model');
|
||||
|
||||
// Appeler la fonction pour récupérer les couvertures d'albums
|
||||
$data['covers'] = $this->Cover_model->get_covers();
|
||||
|
||||
// Charger la vue avec les données récupérées
|
||||
$this->load->view('accueil', $data);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
17
CodeIgniter-3.1.13/application/models/Cover_model.php
Normal file
17
CodeIgniter-3.1.13/application/models/Cover_model.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Cover_model extends CI_Model {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->load->database();
|
||||
}
|
||||
|
||||
public function get_covers() {
|
||||
$query = "SELECT id, jpeg FROM cover LIMIT 4";
|
||||
$result = $this->db->query($query);
|
||||
return $result->result_array();
|
||||
}
|
||||
}
|
||||
?>
|
@ -49,9 +49,14 @@
|
||||
|
||||
<div class="gallery">
|
||||
<h2>Ils nous ont fait confiance</h2>
|
||||
<img src="assets/img/gallerie/pnl.png" alt="PNL">
|
||||
<img src="assets/img/gallerie/booba.png" alt="BOOBA">
|
||||
<img src="assets/img/gallerie/niska.png" alt="NISKA">
|
||||
<?php if (!empty($covers)): ?>
|
||||
<?php foreach ($covers as $cover): ?>
|
||||
<?php
|
||||
$imageData = base64_encode($cover['jpeg']); // Convertir les données binaires en base64
|
||||
?>
|
||||
<img src="data:image/jpeg;base64,<?= $imageData ?>" alt="Image de couverture d'album">
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="contact">
|
||||
|
Loading…
Reference in New Issue
Block a user