Sindbad~EG File Manager

Current Path : /home/u625735752/domains/snackoncrumbs.com/public_html/demo/1.1/
Upload File :
Current File : /home/u625735752/domains/snackoncrumbs.com/public_html/demo/1.1/categories.php

<?php
// Include 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 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;

// Query the total number of categories to calculate the total pages
$total_categories_sql = "SELECT COUNT(*) AS total FROM categories";
$total_result = $conn->query($total_categories_sql);
$total_row = $total_result->fetch_assoc();
$total_categories = $total_row['total'];
$total_pages = ceil($total_categories / $items_per_page);

// Fetch categories for the current page
$sql = "SELECT * FROM categories ORDER BY category_id DESC LIMIT $items_per_page OFFSET $offset";
$result = $conn->query($sql);

?>

<section class="py-5 overflow-hidden">
  <div class="container">
    <div class="row   mb-2 mt-5">
      <div class="col-lg-8 mt-5">
        <h3 class="fw-bold lh-sm text-start text-lg-start">All Categories</h3>
      </div> 
    </div>

    <div class="row">
      <?php if ($result->num_rows > 0): ?>
        <?php while($row = $result->fetch_assoc()): ?>
          <div class="col-6 col-sm-4 col-md-3 col-lg-2 mb-4">
            <div class="card card-span h-100">
              <!-- Link to the products page with the category_id as a query parameter -->
              <a href="products.php?category_id=<?= htmlspecialchars($row['category_id']) ?>">
                <img class="img-fluid  " src="<?= htmlspecialchars($row['image_url']) ?>" alt="<?= htmlspecialchars($row['name']) ?>">
                <div class="card-body ps-0">
                  <h5 class="text-center fw-bold text-1000 text-truncate mb-2"><?= htmlspecialchars($row['name']) ?></h5>
                </div>
              </a>
            </div>
          </div>
        <?php endwhile; ?>
      <?php else: ?>
        <p class="text-center">No categories 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="Category Pagination">
          <!-- Previous Page Button -->
          <?php if ($page > 1): ?>
            <a class="btn btn-outline-primary" href="?page=<?= $page - 1 ?>">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 ?>"><?= $i ?></a>
          <?php endfor; ?>

          <!-- Next Page Button -->
          <?php if ($page < $total_pages): ?>
            <a class="btn btn-outline-primary" href="?page=<?= $page + 1 ?>">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> 
	
  </body>

</html>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists