<?php session_start();
   require_once("./config/config.php");

   $id = $_GET['id'];
   
  
   $sql_blog_id = "SELECT * FROM blog_category_add WHERE addblog = '$id'";
$myquery_blog_id=$conn->query($sql_blog_id);

$mydara_blog_id =$myquery_blog_id->fetchAll();
$row_found_blog_id = $myquery_blog_id->rowCount();
if($row_found_blog_id>0){
    foreach($mydara_blog_id as $row_form){
      $metatitles = $row_form['metatitle'];
      $metadesc = $row_form['metadesc'];
       $metakey = $row_form['metakey'];     
       $images = $row_form['blog_image']; 
       $editor = $row_form['editor1']; 
       $blog_title = $row_form['blogtitle']; 
       $dates = strtotime($row_form['datecreated']); 
       $categorys = $row_form['category'];
    }
   }
 //  echo $metatitles;

     // This is a code for php minifiers Begin
     ob_start("minifier");
     function minifier($code) {
         $search = array(
              
             // Remove whitespaces after tags
             '/\>[^\S ]+/s',
              
             // Remove whitespaces before tags
             '/[^\S ]+\</s',
              
             // Remove multiple whitespace sequences
             '/(\s)+/s',
              
             // Removes comments
             '/<!--(.|\s)*?-->/'
         );
         $replace = array('>', '<', '\\1');
         $code = preg_replace($search, $replace, $code);
         return $code;
     }
     // This is a code for php minifiers End
 
   ?>
<!DOCTYPE html>
<html lang="en">
   <head>
      <!-- Character set configuration -->
      <base href="<?=$base_link?>" target="_self">
      <meta charset="UTF-8" />
      <title><?=$metatitles?></title>
      <meta http-equiv="X-UA-Compatible" content="IE=edge" />
      <link id="favicon" rel="icon" type="image/x-icon" href="images/web-images/home/favicon.png"/>
      <meta name="robots" content="index, follow" />
      <meta name="description" content="<?=$metadesc?>">
      <meta name="keywords" content="<?=$metakey?>">
      <link rel="canonical" href="blog-details.php"/>
      <!-- Viewport configuration, scaling options -->
     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>

      <!-- CSS Stylesheet -->
      <link href="css/icouponworld.css" rel="stylesheet" />
      <!-- Font Awesome icon -->
      <link href="fontawesome/css/fontawesome.css" rel="stylesheet" />
      <!-- Owl Stylesheets -->
      <!-- <link rel="stylesheet" href="css/owl.carousel.min.css">
      <link rel="stylesheet" href="css/owl.theme.default.min.css"> -->
       <!-- Google Analytics Code Begin-->
      <?=$google_ana ?>
        <!-- Google Analytics Code End-->
      <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
      <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
      <![endif]-->
   </head>
   <body>
      <!-- Preloader Begin-->
      <div class="preloader">
         <div class="loading">
            <img src="images/web-images/home/loader.gif" alt="loader" title="loader" class="mx-auto d-flex"> 
            <h2 class="text-center fw-light">loading...</h2>
         </div>
      </div>
      <!-- Preloader End-->
      <!--Header Begin-->
      <?php include("./includefiles/header.php");   ?> 
      <!--Header End-->
      <!--Overlay Begin-->
      <div id="overlay"></div>
      <!--Overlay End-->
      <!--Blog Begin-->
      <section class="bg-white gap-top blg-dtls">
         <div class="container">
            <div class="row">
               <div class="col-md-9">
                  <nav class="b-items pt-5 pb-4" aria-label="breadcrumb">
                     <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="index">Home</a></li>
                        <li class="breadcrumb-item"><a href="blog">Blog</a></li>
                        <li class="breadcrumb-item active" aria-current="page"><?=$categorys?></li>
                     </ol>
                  </nav>
                  <span class="badge fs-12 bg-dark rounded-0"><?=$categorys?></span>
                  <h1 class="h2 pt-2 fw-bold "><?=$blog_title?></h1>
                  <div class="d-flex py-4 border-bottom mb-4">
                     <div class="flex-shrink-0">
                        <img src="./admin/backend/<?=$profile_pic?>" width="40" class="img-fluid" alt="user">
                     </div>
                     <div class="flex-grow-1 ms-3">
                        <h6>
                          <?=$full_name?>
                        </h6>
                        <p class="fs-12 text-muted"><?php echo date("M d, y", $dates);?></p>
                     </div>
                  </div>
                  <img src="./admin/backend/<?=$images?>" class=" img-fluid img-thumbnail my-3">
                  <div>
                     <?php echo htmlspecialchars_decode($editor, ENT_QUOTES);?>
                  </div>

                  <div class="my-4"><?=$google_adfeed?></div>
               </div>
               <div class="col-md-3">
                  <div class="search pt-5 pb-4">
                  
                     <div class="title pt-4">
                        lattest Post
                     </div>
                     <!--lattest-post-right-->
                     <?php
                          $sql_category_way = "SELECT category, COUNT(*) FROM `blog_category_add` GROUP BY category limit 7";
                          $myquery_category_way=$conn->query($sql_category_way);
                          $mydara_category_way =$myquery_category_way->fetchAll();
                          $row_found_category_way = $myquery_category_way->rowCount();
                        // var_dump($mydara_category_way);
                        if( $row_found_category_way>0){
                           foreach($mydara_category_way as $row_form){
                               
                             
                              $categorys1 = $row_form['category'];
                             $count =  $row_form['COUNT(*)'];
                            //echo  $count;
                     ?>
                     <div class="lattest-post-right">
                        <div class="d-flex">
                           <div class="flex-shrink-0">
                              <?php
                                $sql_categorys = "SELECT * FROM blog_category_add  WHERE category = '$categorys1' ORDER BY datecreated DESC  limit 1";
                                $myquery_categorys=$conn->query($sql_categorys);
                                $mydara_categorys =$myquery_categorys->fetchAll();
                                $row_found_categorys = $myquery_categorys->rowCount();
                              // var_dump($mydara_category_way);
                              if( $row_found_categorys>0){
                                 foreach($mydara_categorys as $row_form){
                                     
                                   
                                    $blog_pic = $row_form['blog_image'];
                                    $blog_title1 = $row_form['blogtitle'];
                                   
                           ?>
                              <a href="blog-category/<?=$categorys1?>"><img src="./admin/backend/<?=$blog_pic?>" class="img-fluid rounded-3" alt="img" width="130"></a>
                           </div>
                           <div class="flex-grow-1 ms-3 mt-2">
                              <a href="blog-category/<?=$categorys1?>" class="d-grid text-decoration-none">
                                 <h6 class="fs-12 fw-bold text-truncate"><?=$blog_title1?></h6>
                                 <p class="fst-italic fs-12 text-truncate pt-1"><?=$categorys1?> </p>
                                 <div>
                                    <?php } } ?>
                                    
                                    <span class="badge bg-primary rounded-pill"><?php echo  $count;?></span>
                                   
                                 </div>
                              </a>
                           </div>
                        </div>
                     </div>
                     <?php }  }  ?>
                     <!--Top Stores-->
                     <!--Coupons from Similar Stores Begin-->
   <div class="similar-store">
      <div class="my-4"></div>
      <h6 class="mb-3">popular Brand</h6>
      <ul class="list-unstyled">
         <?php  $sqlcategory="SELECT * FROM  brand_master ORDER BY rand() LIMIT 6";
            $myquerycou=$conn->query($sqlcategory);
            $mydaracategory= $myquerycou->fetchAll()  ;
            
            $rows_foundcou = $myquerycou->rowCount();
            
            foreach( $mydaracategory as $rowcat ){  
            
            $brand_name = addslashes($rowcat["brand_name"]);
            $brand_name1 = strtolower($brand_name);
            if($brand_name!=''){
            ?>
         <li><a title="<?=$brand_name?>" href="brand-specific/<?=($brand_name1)?>"> <?=$brand_name?></a></li>
         <?php } } ?>
      </ul>
   </div>
   <!--Coupons from Similar Stores End-->
   <!--Popular Stores Begin-->
   <div class="similar-store">
      <div class="divider my-3"></div>
      <h6 class="mb-3">Popular Stores</h6>
      <ul class="list-unstyled">
         <?php  $sqlcategory="SELECT * FROM  store_master ORDER BY rand() LIMIT 6";
            $myquerycou=$conn->query($sqlcategory);
            $mydaracategory= $myquerycou->fetchAll()  ;
            
            $rows_foundcou = $myquerycou->rowCount();
            
            foreach( $mydaracategory as $rowcat ){  
            
            $store_name = addslashes($rowcat["store_name"]); 
            $store_name1 = strtolower($store_name);
            if($store_name!=''){
            ?>
         <li><a title="<?=$store_name?>" href="store-specific/<?=($store_name1)?>"><?=$store_name?></a></li>
         <?php } } ?>
      </ul>
   </div>
   <!--Popular Stores End-->
   <div class="mb-3">
    <?php    if(!empty($google_adar )){
      echo $google_adar ;
      }else{
      echo ' <img src="admin/forms/'.$adimg1.'" alt="Vertical Banner" title="Vertical Banner" class="img-fluid rounded-3 mt-2">';
      }
      
      ?>
</div>

   <!--Banner End-->
       <!--Google Ads Begin-->
       <div class="mb-3"><?=$google_addis?></div>
                  </div>
               </div>
            </div>
         </div>
      </section>
      <!--Blog End-->
      <!--footer Section Begin-->
      <?php include("./includefiles/footer.php");   ?>
      <!--footer Section End-->
      <!--scroll to top Begin-->
      <button onclick="topFunction()" id="gobackToTop" title="Go To Top"><i class="fas fa-angle-up"></i></button>
      <!--scroll to top end-->
      <!-- jquery-3.4.1.min js Begin-->
      <script src="js/jquery-3.4.1.min.js"></script>
      <!-- jquery-3.4.1.min js End-->
      <!-- bootstrap.bundle.min js Begin-->
      <script src="js/bootstrap.bundle.min.js"></script>
      <!-- bootstrap.bundle.min js End-->
      <!-- icouponworld js Begin-->
      <script src="js/icouponworld.js"></script>
      <!-- icouponworld js End-->
      <!--script for googleTranslateElementInit Begin-->
      <!-- <script>
         function googleTranslateElementInit() {
  new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
}
      </script> -->
      <!--script for googleTranslateElementInit End-->
      <!--script for googleTranslate Begin-->
      <!-- <script src="js/googletranslate.js"></script> -->
      <!--script for googleTranslate End-->
   </body>
</html>
<?php
ob_end_flush();  // This is a code for php minifiers
?>