<?php require_once('includes/cmain.inc.php');?>
<?php 
$url = explode('/', rtrim($_SERVER["REQUEST_URI"],"/"));
$menuurl = ucwords(str_replace('-', ' ', end($url)));
//print_r("SELECT * FROM tbl_blog WHERE cat_name='".trim($menuurl)."' AND status=1");exit();
$result = db_query("SELECT * FROM tbl_blog WHERE cat_name='".trim($menuurl)."' AND status=1");?>
<?php  include('header.php');

?>
 <!-- Full Screen Search Start -->
    <div class="modal fade" id="searchModal" tabindex="-1">
        <div class="modal-dialog modal-fullscreen">
            <div class="modal-content" style="background: rgba(9, 30, 62, .7);">
                <div class="modal-header border-0">
                    <button type="button" class="btn bg-white btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body d-flex align-items-center justify-content-center">
                    <div class="input-group" style="max-width: 600px;">
                        <input type="text" class="form-control bg-transparent border-primary p-3" placeholder="Type search keyword">
                        <button class="btn btn-primary px-4"><i class="bi bi-search"></i></button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- Full Screen Search End -->
 
   <!-- Hero Start -->
    <div class="container-fluid bg-primary py-5 hero-header mb-5">
        <div class="row py-3">
            <div class="col-12 text-center">
                <h1 class="display-3 text-white animated zoomIn">Blog</h1>
                <a href="" class="h4 text-white">Home</a>
                <i class="far fa-circle text-white px-2"></i>
                <a href="" class="h4 text-white">Blog</a>
            </div>
        </div>
    </div>
    <!-- Hero End -->


        <!-- Blog Start -->
        <div class="container-fluid blog py-5">
            <div class="container py-5">
                
                <div class="row g-4 justify-content-center">
   <?php
$req = $_SERVER['HTTP_HOST'].''.$_SERVER['REQUEST_URI'];
$exsp = explode("=", $req);
$start =$exsp[2] ?? '';
$dsdsd = explode("/", $req);
$poison=$dsdsd[3] ?? '';
$poisonA=explode("?", $poison);
$poisonB=ucwords(str_replace("-"," ",$poisonA[0]));

$start = intval($start);
$pagesize = isset($pagesize) ? intval($pagesize) : 105;
$columns = "select * ";
$sql = " from `tbl_blog` ";
$sql .= " where status= 1 ";
if($poisonB !=""){
  $sql .= "and cat_name LIKE '%$poisonB%'";
}
//$order_by == '' ? $order_by = ' `id`' : true;
//$order_by2 == '' ? $order_by2 = 'DESC' : true;
$sql_count = "select count(*) ".$sql; 
$sql .= "order by id DESC ";
$sql .= "limit $start, $pagesize ";
$sql = $columns.$sql;
$result = db_query($sql);
$reccnt = db_scalar($sql_count);
//print_r($sql);exit();
?>
 <?// include("includes/paging.incBlog.php");?> 
<? 
if($start==0){
  $cnt=0;
}
else{
  $cnt=$start;
}
while ($line_raw = mysqli_fetch_array($result)) {
  $cnt++;
$line = ms_display_value($line_raw);
@extract($line);
$css = isset($css) ? (($css == 'trOdd') ? 'trEven' : 'trOdd') : 'trOdd';
?>
              
                    <div class="col-lg-6 col-xl-4 wow fadeInUp" data-wow-delay="0.2s">
                        <div class="blog-item">
                            <div class="blog-img">
                                <img src="<?php echo SITE_WS_PATH."/uploaded_files/blog/original/".$blog_banner;?>" class="img-fluid rounded-top w-100" alt="">
                                <div class="blog-categiry py-2 px-4">
                                    <span> <?php $fetchSQL = mysqli_fetch_array(db_query("SELECT cat_name from tbl_blog where id='$id' "));
	 $items= explode(",", $fetchSQL['cat_name']); 
	foreach($items as $value){ 
	$dynamicURL= SITE_WS_PATH.'/blog/'.strtolower(str_replace(" ","-",$value));
    echo "<a href='$dynamicURL' class='btn btn-xs btn-primary'>".$value."</a>"; }  ?></span>
                                </div>
                            </div>
                            <div class="blog-content p-4">
                                <!--<div class="blog-comment d-flex justify-content-between mb-3">
                                    <div class="small"><span class="fa fa-user text-primary"></span> Martin.C</div>
                                    <div class="small"><span class="fa fa-calendar text-primary"></span> 30 Dec 2025</div>
                                    <div class="small"><span class="fa fa-comment-alt text-primary"></span> 6 Comments</div>
                                </div>-->
                                <a href="<?php echo SITE_WS_PATH.'/blog/'.$serviceUri=str_replace(" ", "-",strtolower($heading)); ?>" class="h4 d-inline-block mb-3"><?php echo $heading;?></a>
                                <p class="mb-3">
                                <?php $content = $line_raw['content'];

                                 $content = preg_replace('/<style\b[^>]*>(.*?)<\/style>/is', '', $content);
                                 $content = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', '', $content);
                                  $content = preg_replace('/<[^>]+>/', '', $content);
                                  echo substr(($content), 0, 100); ?></p>
                                <a href="<?php echo SITE_WS_PATH.'/blog/'.$serviceUri=str_replace(" ", "-",strtolower($heading)); ?>" class="btn p-0">Read More  <i class="fa fa-arrow-right"></i></a>
                            </div>
                        </div>
                    </div>
    <?php } ?>                
                
                </div>
            </div>
        </div>
        <!-- Blog End -->

<?php include('footer.php');?>