Sindbad~EG File Manager
<?php
// Include the database connection
include 'conn.php';
?>
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- SEO Meta Tags -->
<title>SnackonCrumbs - Delicious Cakes & Snacks Delivered to Your Doorstep</title>
<meta name="description" content="SnackonCrumbs offers fresh and delicious cakes, snacks, and desserts delivered right to your door. Enjoy mouth-watering treats with the best quality and service. Order now!">
<meta name="keywords" content="cakes, snacks, desserts, online cake delivery, snack delivery, fresh cakes, sweet treats, home delivery, bakery">
<meta name="author" content="SnackonCrumbs">
<!-- Open Graph Meta Tags for Social Media Sharing -->
<meta property="og:title" content="SnackonCrumbs - Delicious Cakes & Snacks Delivered to Your Doorstep">
<meta property="og:description" content="Enjoy the convenience of fresh and delicious cakes, snacks, and desserts delivered right to your door. Order now and indulge in the best treats!">
<meta property="og:image" content="https://www.snackoncrumbs.com/assets/img/logo.png"> <!-- Replace with your image URL -->
<meta property="og:url" content="https://www.snackoncrumbs.com">
<meta property="og:type" content="website">
<!-- Twitter Meta Tags for Social Media Sharing -->
<meta name="twitter:title" content="SnackonCrumbs - Delicious Cakes & Snacks Delivered to Your Doorstep">
<meta name="twitter:description" content="Get fresh cakes, snacks, and delicious desserts delivered to your doorstep. Quality snacks with an easy online order experience.">
<meta name="twitter:image" content="https://www.snackoncrumbs.com/assets/img/logo.png"> <!-- Replace with your image URL -->
<meta name="twitter:card" content="summary_large_image">
<!-- Favicon -->
<link rel="icon" href="https://www.snackoncrumbs.com/assets/img/favicon.ico" type="image/x-icon">
<!-- Canonical Link to avoid duplicate content -->
<link rel="canonical" href="https://www.snackoncrumbs.com">
<!-- ===============================================-->
<!-- Stylesheets-->
<!-- ===============================================-->
<link href="assets/css/theme.css" rel="stylesheet" />
</head>
<body>
<!-- ===============================================-->
<!-- Main Content-->
<!-- ===============================================-->
<main class="main" id="top">
<?php include 'nav.php'?>
<?php
// Define the number of items per page
$items_per_page = 12;
// Get the current page number from the URL, default to 1 if not set
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$offset = ($page - 1) * $items_per_page;
// Check if category_id is set in the URL
$category_id = isset($_GET['category_id']) ? (int)$_GET['category_id'] : 0;
// If category_id is set, get the category name from the database
if ($category_id > 0) {
$category_sql = "SELECT name FROM categories WHERE category_id = $category_id";
$category_result = $conn->query($category_sql);
$category_row = $category_result->fetch_assoc();
$category_name = $category_row['name'];
} else {
// If no category_id, set to "All Categories"
$category_name = "All Products";
}
// Query to get the total number of items (with or without category filter)
$total_items_sql = $category_id > 0 ?
"SELECT COUNT(*) AS total FROM menu_items WHERE category_id = $category_id" :
"SELECT COUNT(*) AS total FROM menu_items";
$total_result = $conn->query($total_items_sql);
$total_row = $total_result->fetch_assoc();
$total_items = $total_row['total'];
$total_pages = ceil($total_items / $items_per_page);
// Fetch menu items for the current page (with or without category filter)
$sql = $category_id > 0 ?
"SELECT * FROM menu_items WHERE category_id = $category_id ORDER BY item_id DESC LIMIT $items_per_page OFFSET $offset" :
"SELECT * FROM menu_items ORDER BY item_id DESC LIMIT $items_per_page OFFSET $offset";
$result = $conn->query($sql);
?>
<section class="py-4 overflow-hidden">
<div class="container">
<div class="row mb-2 mt-5">
<div class="col-lg-8 mt-5">
<!-- Dynamically set heading based on category -->
<h3 class="fw-bold lh-sm text-start text-lg-start"><?= htmlspecialchars($category_name) ?></h3>
</div>
</div>
<div class="row gx-3 h-100 align-items-center">
<?php if ($result->num_rows > 0): ?>
<?php while($row = $result->fetch_assoc()): ?>
<div class="col-sm-6 col-md-3 mb-5 mt-7 mb-5">
<form class="product-form">
<input type="hidden" name="item_id" value="<?= htmlspecialchars($row['item_id']) ?>">
<div class="card card-span h-100 rounded-3">
<img class="img-fluid rounded-3 h-100" src="<?= htmlspecialchars($row['image_url']) ?>" alt="<?= htmlspecialchars($row['name']) ?>" />
<div class="card-body ps-0">
<h5 class="fsz-20 fw-bold text-1000 text-truncate mb-1"><?= htmlspecialchars($row['name']) ?></h5>
<div class="new-price fw-bold text-danger mb-2">₹<?= number_format($row['price'], 2) ?></div>
</div>
</div>
<?php if ($row['availability'] === 'available'): ?>
<div class="d-grid">
<button type="button" class="btn btn-lg btn-danger mt-2 add-to-cart-btn w-100" data-item-id="<?= htmlspecialchars($row['item_id']) ?>">Order Now</button>
</div>
<?php else: ?>
<button type="button" class="btn btn-lg btn-danger mt-2 add-to-cart-btn w-100" disabled="">Not Available</button>
<?php endif; ?>
</form>
</div>
<?php endwhile; ?>
<?php else: ?>
<p>No menu items found.</p>
<?php endif; ?>
</div>
<!-- Pagination buttons -->
<div class="row justify-content-center">
<div class="col-auto">
<div class="btn-group" role="group" aria-label="Product Pagination">
<!-- Previous Page Button -->
<?php if ($page > 1): ?>
<a class="btn btn-outline-primary" href="?page=<?= $page - 1 ?>&category_id=<?= $category_id ?>">Previous</a>
<?php else: ?>
<button class="btn btn-outline-secondary" disabled>Previous</button>
<?php endif; ?>
<!-- Page Numbers -->
<?php for ($i = 1; $i <= $total_pages; $i++): ?>
<a class="btn btn-outline-primary <?= $i == $page ? 'active' : '' ?>" href="?page=<?= $i ?>&category_id=<?= $category_id ?>"><?= $i ?></a>
<?php endfor; ?>
<!-- Next Page Button -->
<?php if ($page < $total_pages): ?>
<a class="btn btn-outline-primary" href="?page=<?= $page + 1 ?>&category_id=<?= $category_id ?>">Next</a>
<?php else: ?>
<button class="btn btn-outline-secondary" disabled>Next</button>
<?php endif; ?>
</div>
</div>
</div>
</div>
</section>
<?php include 'footer.php'?>
</main>
<!-- ===============================================-->
<!-- End of Main Content-->
<!-- ===============================================-->
</body>
</html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists