Ajout d'un code en rapideeeeee
This commit is contained in:
3
TP3/code/vues/footer.php
Normal file
3
TP3/code/vues/footer.php
Normal file
@@ -0,0 +1,3 @@
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
14
TP3/code/vues/header.php
Normal file
14
TP3/code/vues/header.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Films</title>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
|
||||
/>
|
||||
|
||||
<link rel="stylesheet" href="./css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<main class="container">
|
35
TP3/code/vues/vueFiche.php
Normal file
35
TP3/code/vues/vueFiche.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<!--
|
||||
Variables de la vue
|
||||
$film : données du film
|
||||
-->
|
||||
|
||||
<h2>Fiche Film</h2>
|
||||
|
||||
<div style="max-width: 600px;">
|
||||
<h3><?= htmlspecialchars($film['titre']) ?></h3>
|
||||
|
||||
<table style="width: 100%; border-collapse: collapse;">
|
||||
<tr>
|
||||
<td style="font-weight: bold; padding: 8px; border: 1px solid #ddd; background-color: #f9f9f9;">Année :</td>
|
||||
<td style="padding: 8px; border: 1px solid #ddd;"><?= htmlspecialchars($film['annee']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="font-weight: bold; padding: 8px; border: 1px solid #ddd; background-color: #f9f9f9;">Genre :</td>
|
||||
<td style="padding: 8px; border: 1px solid #ddd;"><?= htmlspecialchars($film['genre']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="font-weight: bold; padding: 8px; border: 1px solid #ddd; background-color: #f9f9f9;">Réalisateur :</td>
|
||||
<td style="padding: 8px; border: 1px solid #ddd;"><?= htmlspecialchars($film['prenom'] . ' ' . $film['nom']) ?></td>
|
||||
</tr>
|
||||
<?php if (!empty($film['resume'])): ?>
|
||||
<tr>
|
||||
<td style="font-weight: bold; padding: 8px; border: 1px solid #ddd; background-color: #f9f9f9;">Résumé :</td>
|
||||
<td style="padding: 8px; border: 1px solid #ddd;"><?= nl2br(htmlspecialchars($film['resume'])) ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
|
||||
<div style="margin-top: 20px;">
|
||||
<a href="films.php" style="text-decoration: none; color: #0066cc;">← Retour à la liste des films</a>
|
||||
</div>
|
||||
</div>
|
92
TP3/code/vues/vueFilms.php
Normal file
92
TP3/code/vues/vueFilms.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<!--
|
||||
Variables de la vue
|
||||
$films : les films de la page
|
||||
$realisateurs : liste des réalisateurs
|
||||
$realisateur_selectionne : ID du réalisateur sélectionné
|
||||
$tri_actuel : critère de tri actuel
|
||||
$nombreTotal : nombre total de films
|
||||
-->
|
||||
|
||||
<h2>Films</h2>
|
||||
|
||||
<!-- Formulaire de filtrage par réalisateur -->
|
||||
<form method="GET" action="films.php" style="margin-bottom: 20px;">
|
||||
<label for="realisateur">Filtrer par réalisateur :</label>
|
||||
<select name="realisateur" id="realisateur" onchange="this.form.submit()">
|
||||
<option value="">-- Tous les réalisateurs --</option>
|
||||
<?php foreach($realisateurs as $realisateur): ?>
|
||||
<option value="<?= $realisateur['id'] ?>"
|
||||
<?= ($realisateur_selectionne == $realisateur['id']) ? 'selected' : '' ?>>
|
||||
<?= htmlspecialchars($realisateur['prenom'] . ' ' . $realisateur['nom']) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
<!-- Maintenir les autres paramètres -->
|
||||
<input type="hidden" name="tri" value="<?= htmlspecialchars($tri_actuel) ?>">
|
||||
</form>
|
||||
|
||||
<!-- Liens de tri -->
|
||||
<div style="margin-bottom: 15px;">
|
||||
<strong>Trier par :</strong>
|
||||
<?php
|
||||
$url_base = "films.php?";
|
||||
if ($realisateur_selectionne) {
|
||||
$url_base .= "realisateur=" . $realisateur_selectionne . "&";
|
||||
}
|
||||
?>
|
||||
<a href="<?= $url_base ?>tri=titre" <?= ($tri_actuel == 'titre') ? 'style="font-weight: bold;"' : '' ?>>Titre</a> |
|
||||
<a href="<?= $url_base ?>tri=annee" <?= ($tri_actuel == 'annee') ? 'style="font-weight: bold;"' : '' ?>>Année</a> |
|
||||
<a href="<?= $url_base ?>tri=genre" <?= ($tri_actuel == 'genre') ? 'style="font-weight: bold;"' : '' ?>>Genre</a> |
|
||||
<a href="<?= $url_base ?>tri=nom" <?= ($tri_actuel == 'nom') ? 'style="font-weight: bold;"' : '' ?>>Réalisateur</a>
|
||||
</div>
|
||||
|
||||
<!-- Affichage du nombre de résultats -->
|
||||
<p><em><?= count($films) ?> film(s) affiché(s) sur <?= $nombreTotal ?> au total</em></p>
|
||||
|
||||
<!-- Tableau des films -->
|
||||
<table border="1" cellpadding="8" cellspacing="0" style="border-collapse: collapse; width: 100%;">
|
||||
<thead>
|
||||
<tr style="background-color: #f0f0f0;">
|
||||
<th>Titre</th>
|
||||
<th>Année</th>
|
||||
<th>Genre</th>
|
||||
<th>Réalisateur</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($films)): ?>
|
||||
<tr>
|
||||
<td colspan="4" style="text-align: center; font-style: italic;">Aucun film trouvé</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach($films as $film): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="./fiche.php?film=<?= $film['idFilm'] ?>" style="text-decoration: none; color: #0066cc;">
|
||||
<?= htmlspecialchars($film['titre']) ?>
|
||||
</a>
|
||||
</td>
|
||||
<td><?= htmlspecialchars($film['annee']) ?></td>
|
||||
<td><?= htmlspecialchars($film['genre']) ?></td>
|
||||
<td><?= htmlspecialchars($film['prenom'] . ' ' . $film['nom']) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- Exemple de limitation avec LIMIT -->
|
||||
<div style="margin-top: 20px;">
|
||||
<strong>Affichage limité :</strong>
|
||||
<?php
|
||||
$url_limit = "films.php?";
|
||||
if ($realisateur_selectionne) {
|
||||
$url_limit .= "realisateur=" . $realisateur_selectionne . "&";
|
||||
}
|
||||
$url_limit .= "tri=" . $tri_actuel . "&";
|
||||
?>
|
||||
<a href="<?= $url_limit ?>limit=5">5 premiers</a> |
|
||||
<a href="<?= $url_limit ?>limit=10">10 premiers</a> |
|
||||
<a href="<?= $url_limit ?>">Tous</a>
|
||||
</div>
|
Reference in New Issue
Block a user