Files
web_2025/R3.01/tp/tp3/cinema/src/vues/vueFilms.php
T

65 lines
1.7 KiB
PHP
Raw Normal View History

2026-04-08 16:10:49 +02:00
<!--
Variables de la vue
$films : les films de la page
2026-04-08 08:49:36 +02:00
-->
<h2>Films</h2>
2026-04-08 16:10:49 +02:00
<?php if (!empty($errorMessage)) { ?>
<article><?php echo htmlspecialchars($errorMessage, ENT_QUOTES, 'UTF-8'); ?></article>
<?php } ?>
2026-04-08 08:49:36 +02:00
<table>
2026-04-08 16:10:49 +02:00
<thead>
<tr>
<th>Titre</th>
<th>Année</th>
<th>Genre</th>
<th>Réalisateur</th>
</tr>
</thead>
<tbody>
2026-04-08 08:49:36 +02:00
<?php
2026-04-08 16:10:49 +02:00
foreach ($films as $film) {
$titre = htmlspecialchars($film['titre'], ENT_QUOTES, 'UTF-8');
$annee = htmlspecialchars((string) $film['annee'], ENT_QUOTES, 'UTF-8');
$genre = htmlspecialchars($film['genre'], ENT_QUOTES, 'UTF-8');
$realisateur = htmlspecialchars($film['prenom'] . ' ' . $film['nom'], ENT_QUOTES, 'UTF-8');
2026-04-08 08:49:36 +02:00
2026-04-08 16:10:49 +02:00
echo "
<tr>
<td><a href='#'>{$titre}</a></td>
<td>{$annee}</td>
<td>{$genre}</td>
<td>{$realisateur}</td>
</tr>";
2026-04-08 08:49:36 +02:00
}
?>
2026-04-08 16:10:49 +02:00
</tbody>
2026-04-08 08:49:36 +02:00
</table>
2026-04-08 16:10:49 +02:00
<?php if ($totalPages > 1) { ?>
<nav>
<ul>
<li>
<?php if ($currentPage > 1) { ?>
<a href="?page=<?php echo $currentPage - 1; ?>">Précédent</a>
<?php } else { ?>
<span>Précédent</span>
<?php } ?>
</li>
</ul>
<ul>
<li>Page <?php echo $currentPage; ?> / <?php echo $totalPages; ?></li>
</ul>
<ul>
<li>
<?php if ($currentPage < $totalPages) { ?>
<a href="?page=<?php echo $currentPage + 1; ?>">Suivant</a>
<?php } else { ?>
<span>Suivant</span>
<?php } ?>
</li>
</ul>
</nav>
<?php } ?>