54 lines
1.9 KiB
PHP
54 lines
1.9 KiB
PHP
<?php
|
|
require_once 'header.php';
|
|
require_once 'db/config.php';
|
|
|
|
if (!isset($_GET['id'])) {
|
|
echo "<div class='alert alert-danger'>Restaurant ID is missing.</div>";
|
|
require_once 'footer.php';
|
|
exit;
|
|
}
|
|
|
|
$restaurant_id = $_GET['id'];
|
|
|
|
// Fetch restaurant details
|
|
$stmt = db()->prepare("SELECT * FROM restaurants WHERE id = ?");
|
|
$stmt->execute([$restaurant_id]);
|
|
$restaurant = $stmt->fetch();
|
|
|
|
// Fetch menu items
|
|
$stmt = db()->prepare("SELECT * FROM menu_items WHERE restaurant_id = ?");
|
|
$stmt->execute([$restaurant_id]);
|
|
$menu_items = $stmt->fetchAll();
|
|
|
|
?>
|
|
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<h1 class="mt-5"><?php echo htmlspecialchars($restaurant['name']); ?></h1>
|
|
<p class="lead"><?php echo htmlspecialchars($restaurant['description']); ?></p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<?php foreach ($menu_items as $item): ?>
|
|
<div class="col-md-4">
|
|
<div class="card mb-4">
|
|
<div class="card-body">
|
|
<h5 class="card-title"><?php echo htmlspecialchars($item['name']); ?></h5>
|
|
<p class="card-text"><?php echo htmlspecialchars($item['description']); ?></p>
|
|
<p class="card-text font-weight-bold">$<?php echo htmlspecialchars($item['price']); ?></p>
|
|
<form action="cart_actions.php?action=add" method="post">
|
|
<input type="hidden" name="menu_item_id" value="<?php echo $item['id']; ?>">
|
|
<input type="number" name="quantity" value="1" min="1" class="form-control mb-2">
|
|
<button type="submit" class="btn btn-primary">Add to Cart</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<?php require_once 'footer.php'; ?>
|