55 lines
2.7 KiB
PHP
55 lines
2.7 KiB
PHP
<?php include 'header.php'; ?>
|
|
|
|
<main>
|
|
<section class="hero">
|
|
<div class="hero-content">
|
|
<h1>Order from Majuro's best</h1>
|
|
<input type="text" id="search-input" class="search-bar" placeholder="Search restaurants or cuisines...">
|
|
</div>
|
|
</section>
|
|
|
|
<div class="container">
|
|
<h2 class="page-title">All Restaurants</h2>
|
|
|
|
<section class="restaurant-list">
|
|
<div class="restaurant-grid" id="restaurant-grid">
|
|
<?php
|
|
require_once 'db/config.php';
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->query("SELECT id, name, cuisine, image_url, rating, rating_count FROM restaurants ORDER BY name");
|
|
$restaurants = $stmt->fetchAll();
|
|
|
|
foreach ($restaurants as $restaurant) {
|
|
echo '<a href="menu.php?id=' . htmlspecialchars($restaurant['id']) . '" class="restaurant-card" data-name="' . htmlspecialchars(strtolower($restaurant['name'])) . '" data-cuisine="' . htmlspecialchars(strtolower($restaurant['cuisine'])) . '">';
|
|
echo '<img src="' . htmlspecialchars($restaurant['image_url']) . '" alt="' . htmlspecialchars($restaurant['name']) . '">';
|
|
echo '<div class="restaurant-card-content">';
|
|
echo '<h3>' . htmlspecialchars($restaurant['name']) . '</h3>';
|
|
echo '<p>' . htmlspecialchars($restaurant['cuisine']) . '</p>';
|
|
if (isset($restaurant['rating']) && $restaurant['rating'] > 0) {
|
|
echo '<div class="rating-display">';
|
|
echo '<span class="star">★</span>';
|
|
echo '<span>' . htmlspecialchars(number_format($restaurant['rating'], 1)) . '</span>';
|
|
echo '<span class="rating-count">(' . htmlspecialchars($restaurant['rating_count']) . ' ratings)</span>';
|
|
echo '</div>';
|
|
} else {
|
|
echo '<div class="rating-display"><span class="rating-count">No ratings yet</span></div>';
|
|
}
|
|
echo '</div>';
|
|
echo '</a>';
|
|
}
|
|
} catch (PDOException $e) {
|
|
echo '<p>Error: Could not fetch restaurants from the database.</p>';
|
|
}
|
|
?>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
</main>
|
|
|
|
<footer>
|
|
<p>© <?php echo date("Y"); ?> Majuro Eats. All Rights Reserved.</p>
|
|
</footer>
|
|
|
|
</body>
|
|
</html>
|