<?php
require_once "./Functions/Films/getFilmImagePath.php";
?>
<div class="hero main-home">
<h2>Experience Cinema Like Never Before</h2>
</div>
<section>
<h3>🎬 Now Showing</h3>
<div class="film-grid">
<?php
$sql = "SELECT pk_filmID, title, issuedDate FROM citeLeParis_film";
$result = mysqli_query($dbc, $sql);
if ($result && mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$title = $row['title'];
$issuedTime = $row['issuedDate'] ? date("Y-m-d - H:i", strtotime($row['issuedDate'])) : 'N/A'; // convert from 2025-03-30 21:30:00 to 21:30
$fullImagePath = getFilmImagePath($title, $row['imagePath'] ?? "Assets/Images/Films/");
echo '
<a href="index.php?page=film_detail&film_id=' . $row["pk_filmID"] . '" class="film-card-link">
<div class="film-card">
<img src="' . htmlspecialchars($fullImagePath) . '" alt="' . htmlspecialchars($title) . ' poster"
onerror="this.onerror=null; this.src=\'Assets/Images/Icons/image_not_found.svg\';">
<div class="film-info">
<h4>' . htmlspecialchars($title) . '</h4>
<p>🕔 ' . $issuedTime . ' | 🏫 Room 1 </p>
</div>
</div>
</a>';
}
} else {
showMessage("No films found");
}
?>
</div>
</section>