34968-vm/index.php
Flatlogic Bot acff14d6dc V24
2025-10-16 20:45:21 +00:00

97 lines
4.4 KiB
PHP

<?php
require_once 'header.php';
require_once 'hero.php';
require_once 'db/config.php';
// Fetch top-rated restaurants
$stmt = $pdo->query("
SELECT r.*, AVG(ra.rating) as avg_rating
FROM restaurants r
LEFT JOIN ratings ra ON r.id = ra.restaurant_id
GROUP BY r.id
ORDER BY avg_rating DESC
LIMIT 6
");
$top_restaurants = $stmt->fetchAll();
// Fetch featured cuisines
$stmt = $pdo->query("SELECT * FROM cuisines ORDER BY name ASC LIMIT 6");
$cuisines = $stmt->fetchAll();
?>
<div class="container mt-5 mb-5">
<section id="how-it-works" class="text-center">
<h2 class="section-title">How It Works</h2>
<div class="row">
<div class="col-md-4">
<div class="step">
<img src="assets/images/step1.svg" alt="Step 1: Choose a restaurant" class="step-icon">
<h3>Choose A Restaurant</h3>
<p>Browse from our extensive list of local restaurants.</p>
</div>
</div>
<div class="col-md-4">
<div class="step">
<img src="assets/images/step2.svg" alt="Step 2: Pick your meal" class="step-icon">
<h3>Pick Your Meal</h3>
<p>Select your favorite dishes and add them to your cart.</p>
</div>
</div>
<div class="col-md-4">
<div class="step">
<img src="assets/images/step3.svg" alt="Step 3: Fast delivery" class="step-icon">
<h3>Fast Delivery</h3>
<p>Get your food delivered right to your doorstep, fast!</p>
</div>
</div>
</div>
</section>
<section id="restaurants" class="mt-5">
<h2 class="section-title text-center">Top-Rated Restaurants</h2>
<div class="row">
<?php if (count($top_restaurants) > 0): ?>
<?php foreach ($top_restaurants as $restaurant): ?>
<div class="col-md-4 mb-4">
<div class="card restaurant-card">
<a href="menu.php?restaurant_id=<?php echo $restaurant['id']; ?>">
<img src="<?php echo htmlspecialchars($restaurant['image_url']); ?>" class="card-img-top" alt="<?php echo htmlspecialchars($restaurant['name']); ?>">
</a>
<div class="card-body">
<h5 class="card-title"><a href="menu.php?restaurant_id=<?php echo $restaurant['id']; ?>"><?php echo htmlspecialchars($restaurant['name']); ?></a></h5>
<p class="card-text text-muted"><?php echo htmlspecialchars(substr($restaurant['description'], 0, 80)); ?>...</p>
<div class="d-flex justify-content-between align-items-center">
<span class="badge bg-success"><?php echo number_format($restaurant['avg_rating'], 1); ?> ★</span>
<a href="menu.php?restaurant_id=<?php echo $restaurant['id']; ?>" class="btn btn-sm btn-outline-primary">View Menu</a>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
<?php else: ?>
<p class="text-center">No restaurants found.</p>
<?php endif; ?>
</div>
</section>
<section id="cuisines" class="mt-5">
<h2 class="section-title text-center">Featured Cuisines</h2>
<div class="row justify-content-center">
<?php if (count($cuisines) > 0): ?>
<?php foreach ($cuisines as $cuisine): ?>
<div class="col-md-2 col-sm-4 col-6 text-center mb-4">
<a href="restaurants.php?cuisine_id=<?php echo $cuisine['id']; ?>" class="cuisine-card">
<img src="<?php echo htmlspecialchars($cuisine['image_url']); ?>" alt="<?php echo htmlspecialchars($cuisine['name']); ?>" class="img-fluid">
<h5 class="mt-2"><?php echo htmlspecialchars($cuisine['name']); ?></h5>
</a>
</div>
<?php endforeach; ?>
<?php else: ?>
<p class="text-center">No cuisines found.</p>
<?php endif; ?>
</div>
</section>
</div>
<?php require_once 'footer.php'; ?>