<?php
require('connection.inc.php');
require('security.php');

// Extract slug from REQUEST_URI
$requestUri = $_SERVER['REQUEST_URI'];
$slug = basename(parse_url($requestUri, PHP_URL_PATH)); // gets the last segment

if (!$slug) {
    header("Location: blog.php");
    exit;
}

$stmt = $conn->prepare("SELECT * FROM blogs WHERE blog_url_name = ? AND deleted_at IS NULL");
$stmt->bind_param("s", $slug);
$stmt->execute();
$result = $stmt->get_result();

if ($result->num_rows === 0) {
    echo "Blog not found.";
    exit;
}

$blog = $result->fetch_assoc();


$cartCount = 0;

if (isset($_SESSION['user_id'])) {
    $user_id = $_SESSION['user_id'];
    $stmt = $conn->prepare("SELECT COUNT(*) FROM (SELECT 1 FROM cart WHERE user_id = ? GROUP BY product_id, unit_id) AS distinct_items");
    $stmt->bind_param("i", $user_id);
    $stmt->execute();
    $stmt->bind_result($cartCount);
    $stmt->fetch();
    $stmt->close();
}
?>


<!doctype html>
<html class="no-js" lang="zxx">
<head>
      <meta charset="utf-8">
      <meta http-equiv="x-ua-compatible" content="ie=edge">
      <link rel="canonical" href="https://digitalcardwale.com/loveberi/blog-details.php/<?= urlencode($slug) ?>" />
<title><?= $blog['meta_tittle'] ?></title>
<meta name="description" content="<?= $blog['meta_description'] ?>">
<meta name="keywords" content="<?= $blog['meta_key'] ?>">

      <meta name="viewport" content="width=device-width, initial-scale=1">

      <!-- Place favicon.ico in the root directory -->
      <link rel="shortcut icon" type="image/x-icon" href="../assets/img/allnew/logo.png">

      <!-- CSS here -->
      <link rel="stylesheet" href="../assets/css/bootstrap.min.css">
      <link rel="stylesheet" href="../assets/css/animate.css">
      <link rel="stylesheet" href="../assets/css/swiper-bundle.css">
      <link rel="stylesheet" href="../assets/css/slick.css">
      <link rel="stylesheet" href="../assets/css/magnific-popup.css">
      <link rel="stylesheet" href="../assets/css/spacing.css">
      <link rel="stylesheet" href="../assets/css/meanmenu.css">
      <link rel="stylesheet" href="../assets/css/nice-select.css">
      <link rel="stylesheet" href="../assets/css/fontawesome.min.css">
      <link rel="stylesheet" href="../assets/css/icon-dukamarket.css">
      <link rel="stylesheet" href="../assets/css/jquery-ui.css">
      <link rel="stylesheet" href="../assets/css/main.css">
      
      <style>
              .tp-blog-details__wrapper {
        padding: 35px 0px 30px 180px !important;
    }
      </style>
   </head>
   <body>


      <!-- Scroll-top -->
      <button class="scroll-top scroll-to-target" data-target="html">
         <i class="icon-chevrons-up"></i>
      </button>
      <!-- Scroll-top-end-->


<header>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
         <div class="header__top theme-bg-1 d-none d-md-block ps-5 pe-5">
            <div class="container-fluid">
               <div class="row align-items-center">
                  <div class="col-lg-6 col-md-12">
                     <div class="header__top-left">
                        <span>Best quality berries? Let us be your first and last stop for it.</span>
                     </div> 
                  </div>
                  <div class="col-lg-6 col-md-12">
  <div class="d-flex justify-content-end align-items-center">
    <div class="text-white me-2">
    <?php
    if (isset($_SESSION['username'])) {
        echo '<a href="index.php">Welcome, ' . htmlspecialchars($_SESSION['username']) . '</a>';
    } else {
        echo '<a href="log-in.php">Login/Register</a>';
    }
    ?>
    </div>
       <div class="header__top-right d-flex align-items-center gap-3">
      <a href="https://www.facebook.com/profile.php?id=61550353618807" target="_blank" class="text-white"><i class="fab fa-facebook-f"></i></a>
      <a href="https://x.com/ethnic_foods" target="_blank" class="text-white"><i class="fab fa-twitter"></i></a>
      <a href="https://www.youtube.com/@EthnicFoodProduct" target="_blank" class="text-white"><i class="fab fa-youtube"></i></a>
      <a href="https://www.instagram.com/ethnicfoodproduct/" target="_blank" class="text-white"><i class="fab fa-instagram"></i></a>
    </div>
  </div>
</div>

               </div>
            </div>
         </div>
         <div id="header-sticky" class="header__main-area d-none d-xl-block p-2">
            <div class="container-fluid">
               <div class="header__for-megamenu p-relative">
                  <div class="row align-items-center">
                     <div class="col-xl-3">
                        <div class="header__logo ps-5">
                           <a href="../index.php"><img src="../assets/img/allnew/logo.png" alt="logo"></a>
                        </div>
                     </div>
                     <div class="col-xl-4">
                        <div class="header__menu main-menu text-center">
                           <nav id="mobile-menu">
                              <ul>
                                 <li >
                                    <a href="../index.php">Home</a>
                                 </li>
                                 <li><a href="../product.php">Shop</a></li>
                                 <li><a href="../about.php">About Us</a></li>
                                 <li><a href="../contact.php">Contact Us</a></li>
                                 <li>
                                    <a href="../blog.php">Blog</a>
                                 </li>
                              </ul>
                           </nav>
                        </div>
                     </div>
                     <div class="col-xl-5">
                        <div class="header__info d-flex align-items-center pe-5">
                          <div class="header__info-user tpcolor__yellow ml-10">
                            <?php if (isset($_SESSION['username'])): ?>
                            <a href="javascript:void(0)" class="user-icon" onclick="toggleDropdown()">
                                <i class="icon-user"></i>
                            </a>
                            <?php endif; ?>
                            <div id="dropdownMenu" class="dropdown-menu">
                                <a href="../order.php" class="dropdown-item">Order Page</a>
                                <a href="../wishlist.php" class="dropdown-item">Wishlist</a>
                                <a href="../logout.php" class="dropdown-item">Logout</a>
                            </div>
                        </div>
<style>
    .dropdown-menu {
        display: none;
        position: absolute;
        background-color: #fff;
        border: 1px solid #ccc;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        z-index: 1000;
    }

    .dropdown-item {
        padding: 10px;
        text-decoration: none;
        color: #333;
        display: block;
    }

    .dropdown-item:hover {
        background-color: #f1f1f1;
    }
    
    @media(max-width: 768px){
        .tp-blog-details__wrapper {
     padding: 0px 0px 0px 0px !important; 
}
    }
</style>
<script>
    function toggleDropdown() {
    const dropdown = document.getElementById("dropdownMenu");
    dropdown.style.display = (dropdown.style.display === "block") ? "none" : "block";
}

</script>
                          
<div class="header__info-cart tpcolor__oasis ml-10 tp-cart-toggle">
    <a href="cart.php"><i><img src="../assets/img/icon/cart-1.svg" alt=""></i></a>
    <span><?php echo $cartCount; ?></span>
</div>

                        </div>
                     </div>
                  </div>
               </div>
            </div>
         </div>

         <!-- header-search -->
         <div class="tpsearchbar tp-sidebar-area">
            <button class="tpsearchbar__close"><i class="icon-x"></i></button>
            <div class="search-wrap text-center">
                <div class="container">
                    <div class="row justify-content-center">
                        <div class="col-6 pt-100 pb-100">
                            <h2 class="tpsearchbar__title">What Are You Looking For?</h2>
                            <div class="tpsearchbar__form">
                                <form action="#">
                                    <input type="text" name="search" placeholder="Search Product...">
                                    <button class="tpsearchbar__search-btn"><i class="icon-search"></i></button>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
         </div>
         <div class="search-body-overlay"></div>
         <!-- header-search-end -->

         <!-- header-cart-start -->
        
         <div class="cartbody-overlay"></div>
         <!-- header-cart-end -->

         <!-- mobile-menu-area -->
         <div id="header-sticky-2" class="tpmobile-menu d-xl-none">
            <div class="container-fluid">
               <div class="row align-items-center">
                  <div class="col-lg-4 col-md-4 col-3 col-sm-3">
                     <div class="mobile-menu-icon">
                        <button class="tp-menu-toggle"><i class="icon-menu1"></i></button>
                     </div>
                  </div>
                  <div class="col-lg-4 col-md-4 col-6 col-sm-4">
                     <div class="header__logo text-center">
                        <a href="../index.php"><img src="../assets/img/allnew/logo.png" alt="logo"></a>
                     </div>
                  </div>
                  <div class="col-lg-4 col-md-4 col-3 col-sm-5">
                     <div class="header__info d-flex align-items-center">
                        <div class="header__info-search tpcolor__purple ml-10 d-none d-sm-block">
                           <button class="tp-search-toggle"><i class="icon-search"></i></button>
                        </div>
                        <div class="header__info-user tpcolor__yellow ml-10 d-none d-sm-block">
                           <a href="#"><i class="icon-user"></i></a>
                        </div>
                       
                        <div class="header__info-cart tpcolor__oasis ml-10 tp-cart-toggle">
                           <a href="../cart.php"><button><i><img src="../assets/img/icon/cart-1.svg" alt=""></i>
                            
                           </button></a>
                        </div>
                     </div>
                  </div>
               </div>
            </div>
         </div>
         <div class="body-overlay"></div>
         <!-- mobile-menu-area-end -->

         <!-- sidebar-menu-area -->
         <div class="tpsideinfo">
            <button class="tpsideinfo__close">Close<i class="fal fa-times ml-10"></i></button>
            <div class="tpsideinfo__search text-center pt-35">
               <span class="tpsideinfo__search-title mb-20">What Are You Looking For?</span>
               <form action="#">
                  <input type="text" placeholder="Search Products...">
                  <button><i class="icon-search"></i></button>
               </form>
            </div>
            <div class="tpsideinfo__nabtab">
               
                <div class="tab-content" id="pills-tabContent">
                  <div class="tab-pane fade show active" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab" tabindex="0">
                     <div class="mobile-menu"></div>
                  </div>
                  <div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab" tabindex="0">
                     <div class="tpsidebar-categories">
                        <ul>
                           <li><a href="shop-details.php">Dairy Farm</a></li>
                           <li><a href="shop-details.php">Healthy Foods</a></li>
                           <li><a href="shop-details.php">Lifestyle</a></li>
                           <li><a href="shop-details.php">Organics</a></li>
                           <li><a href="shop-details.php">Photography</a></li>
                           <li><a href="shop-details.php">Shopping</a></li>
                           <li><a href="shop-details.php">Tips & Tricks</a></li>
                        </ul>
                     </div>
                  </div>
                </div>
            </div>
            <div class="tpsideinfo__account-link">							
               <a href="log-in.php"><i class="icon-user icons"></i> Login / Register</a>
            </div>
            
         </div> 
         <!-- sidebar-menu-area-end -->
      </header>

      <main>

         <!-- breadcrumb-area-start -->
         <div class="breadcrumb__area pt-5 pb-5">
            <div class="container">
               <div class="row">
                  <div class="col-lg-12">
                     <div class="tp-breadcrumb__content">
                        <div class="tp-breadcrumb__list">
                           <span class="tp-breadcrumb__active"><a href="../index.php">Home</a></span>
                           <span class="dvdr">/</span>
                           <span class="tp-breadcrumb__active"><a href="../blog.php">Blogs </a></span>
                           <span class="dvdr">/</span>
                           <span>  <?= htmlspecialchars($blog['blog_name']) ?></span>
                        </div>
                     </div>
                  </div>
               </div>
            </div>
         </div>
         <!-- breadcrumb-area-end -->

         <!-- blog-details-area-start -->
        <!-- blog-details-area-start -->
<section class="blog-details-area pb-50 pt-80">
   <div class="container">
      <div class="row">
         <div class="col-lg-12">
            <div class="tp-blog-details__thumb">
               <img src="../admin/<?= htmlspecialchars($blog['blog_img']) ?>" alt="<?= htmlspecialchars($blog['blog_name']) ?>">
            </div>
         </div>
      </div>
      <div class="row">
         <div class="col-xl-10 col-lg-12">
            <div class="tp-blog-details__wrapper">
               <div class="tp-blog-details__content">
                  <div class="tpblog__entry-wap mb-5">
                   
                     <span class="post-data">
                        <a href="#"><?= date("M d, Y", strtotime($blog['created_at'])) ?></a>
                     </span>
                  </div>
                  <h2 class="tp-blog-details__title mb-25">
                     <?= htmlspecialchars($blog['blog_name']) ?>
                  </h2>
                  <?= $blog['blog_description'] ?>
               </div>
            </div>
         </div>
      </div>
   </div>
</section>
<!-- blog-details-area-end -->

         <!-- blog-details-area-end -->
         
       

      </main>

      <!-- footer-area-start -->
   <section class="feature-area mainfeature__bg grey-bg pt-50 pb-40" data-background="../assets/img/shape/footer-shape-1.svg">
            <div class="container">
               <div class="mainfeature__border pb-15">
                  <div class="row row-cols-lg-4 row-cols-md-3 row-cols-2">
                     <div class="col">
                        <div class="mainfeature__item text-center mb-30">
                           <div class="mainfeature__icon">
                              <img src="../assets/img/icon/feature-icon-1.svg" alt="">
                           </div>
                           <div class="mainfeature__content">
                              <h4 class="mainfeature__title">Fast Delivery</h4>
                              <p>Across West & East India</p>
                           </div>
                        </div>
                     </div>
                     <div class="col">
                        <div class="mainfeature__item text-center mb-30">
                           <div class="mainfeature__icon">
                              <img src="../assets/img/icon/feature-icon-2.svg" alt="">
                           </div>
                           <div class="mainfeature__content">
                              <h4 class="mainfeature__title">safe payment</h4>
                              <p>100% Secure Payment</p>
                           </div>
                        </div>
                     </div>
                     <div class="col">
                        <div class="mainfeature__item text-center mb-30">
                           <div class="mainfeature__icon">
                              <img src="../assets/img/icon/feature-icon-3.svg" alt="">
                           </div>
                           <div class="mainfeature__content">
                              <h4 class="mainfeature__title">Online Discount</h4>
                              <p>Add Multi-buy Discount </p>
                           </div>
                        </div>
                     </div>
                     <div class="col">
                        <div class="mainfeature__item text-center mb-30">
                           <div class="mainfeature__icon">
                              <img src="../assets/img/icon/feature-icon-4.svg" alt="">
                           </div>
                           <div class="mainfeature__content">
                              <h4 class="mainfeature__title">Help Center</h4>
                              <p>Dedicated 24/7 Support </p>
                           </div>
                        </div>
                     </div>
                     
                  </div>
               </div>
            </div>
            
         </section>
         <footer>
         <div class="tpfooter__area theme-bg-2">
            <div class="tpfooter__top pb-15">
               <div class="container">
                  <div class="row">
                     
                     <div class="col-xl-3 col-lg-4 col-md-6 col-sm-6">
                        <div class="tpfooter__widget footer-col-2 mb-50">
                           <h4 class="tpfooter__widget-title"><img src="../assets/img/WhiteLogo.png" height="150px"></h4>
                           <p>Address <br> </p>
                           <div class="tpfooter__widget-time-info mt-35">
                              <span>Monday – Friday: <b>8:10 AM – 6:10 PM</b></span>
                              <span>Saturday: <b>10:10 AM – 06:10 PM</b></span>
                              <span>Sunday: <b>Close</b></span>
                           </div>
                        </div>
                     </div>
                     <div class="col-xl-3 col-lg-4 col-md-6 col-sm-6">
                        <div class="tpfooter__widget footer-col-1 mb-50">
                           <h4 class="tpfooter__widget-title">Customer Support</h4>
                           
                           <div class="tpfooter__widget-links">
                              <ul>
                                 <li><a href="../cancel.php">Cancellation & Refund</a></li>
                                 <li><a href="../privacypolicy.php">Privacy Policy</a></li>
                                 <li><a href="../s&d.php">Shipping & Delivery</a></li>
                                 <li><a href="../terms.php">Terms & Condition</a></li>
                                 
                              </ul>
                           </div>
                        </div>
                     </div>
                     <div class="col-xl-2 col-lg-4 col-md-4 col-sm-5">
                        <div class="tpfooter__widget footer-col-3 mb-50">
                           <h4 class="tpfooter__widget-title">Quick Links</h4>
                           <div class="tpfooter__widget-links">
                              <ul>
                                 <li><a href="../index.php">Home</a></li>
                                 <li><a href="../about.php">About Us</a></li>
                                 <li><a href="../contactus.php">Contact Us</a></li>
                                 <li><a href="../Blog.php">Blog</a></li>
                              </ul>
                           </div>
                        </div>
                     </div>
                     <div class="col-xl-4 col-lg-6 col-md-8 col-sm-7">
                        <div class="tpfooter__widget footer-col-4 mb-50">
                           <h4 class="tpfooter__widget-title">Our newsletter</h4>
                           <div class="tpfooter__widget-newsletter">
                           <iframe
                                src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3770.5884245265042!2d73.00838082418423!3d19.081825101791654!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x3be7c1394978006b%3A0x12fd6d16abacf57!2sCommodity%20Exchange!5e0!3m2!1sen!2sin!4v1703678311152!5m2!1sen!2sin"
                                width="400" height="200" style="border:0;" allowfullscreen="" loading="lazy"
                                referrerpolicy="no-referrer-when-downgrade"></iframe>
                           </div>
                        </div>
                     </div>
                  </div>
               </div>
            </div>
            <div class="tpfooter___bottom pt-40 pb-40">
               <div class="container">
                  <div class="row">
                     <div class="col-lg-6 col-md-7 col-sm-12">
                        <div class="tpfooter__copyright">
                           <span class="tpfooter__copyright-text">Copyright © <a href="#">Love Beri</a> all rights reserved. Developed by <a target="_blank" href="https://hsdigitalmedia.com/">HS Digital Media®</a>.</span>
                        </div>
                     </div>
                     
                  </div>
               </div>
            </div>
         </div>
      </footer>
      <!-- footer-area-end -->
      

      <!-- JS here -->
      <script src="../assets/js/jquery.js"></script>
      <script src="../assets/js/waypoints.js"></script>
      <script src="../assets/js/bootstrap.bundle.min.js"></script>
      <script src="../assets/js/swiper-bundle.js"></script>
      <script src="../assets/js/nice-select.js"></script>
      <script src="../assets/js/slick.js"></script>
      <script src="../assets/js/magnific-popup.js"></script>
      <script src="../assets/js/counterup.js"></script>
      <script src="../assets/js/wow.js"></script>
      <script src="../assets/js/isotope-pkgd.js"></script>
      <script src="../assets/js/imagesloaded-pkgd.js"></script>
      <script src="../assets/js/countdown.js"></script>
      <script src="../assets/js/ajax-form.js"></script>
      <script src="../assets/js/jquery-ui.js"></script>
      <script src="../assets/js/meanmenu.js"></script>
      <script src="../assets/js/main.js"></script>
   </body>
</html>
