<?php require_once('includes/cmain.inc.php');?>

<?php
$url = explode('/', rtrim($_SERVER["REQUEST_URI"],"/")); 
$count=count($url);
$urltag=str_replace('-',' ',trim($url[2]));
$urls= SITE_WS_PATH.'/'.$url[1];
$menuurl = ucwords(str_replace('-', ' ',$url[$count-1]));
//print_r($menuurl);exit();
$sqlmenu=db_query("SELECT cat_name FROM `tbl_blog`  where cat_name='".trim($menuurl)."' and status=1");
$menu=mysqli_fetch_array($sqlmenu);
$cat_name=$menu['cat_name'];
//print_r($menu['cat_name']);exit();
$titlekb = "Knowledge Base Tags";
$descriptionkb= "Knowledge Base Tags";
$keywordkb="Knowledge Base Tags";
?>
<?php include('header.php'); ?>

<?php

//------------ start of knowledge base------------------?>
<div id="content">
<br />
<div class="container">
    	<ol class="breadcrumb breadcrumb-arrow">
  <li><a href="<?php echo SITE_WS_PATH; ?>">Home</a></li>
  <li><a href="<?php echo SITE_WS_PATH.'/knowledge-base';?>"> Knowledge Base</a></li>
  <li class="active"><span><?php echo $menuurl; ?></span></li>
</ol>
    <div class="col-md-12" style="margin-bottom:20px;" >
      <ol class="breadcrumb y">

<p class="rblo">Blog Category:</p>
<!--<p class="btn readmm"><?// echo $menu['cat_name'];?> </p>-->
<?php 
//print_r("SELECT catP_Name from tbl_blogcatp where status=1 and catP_Name='$cat_name'");exit();
$blogCount=db_query("SELECT catP_Name from tbl_blogcatp where status=1 and catP_Name='".$cat_name."'");
while($blogWs=mysqli_fetch_array($blogCount)){
	$blogCountA=db_query("SELECT cat_name from tbl_blog where cat_name LIKE '".$cat_name."'");
    $count=0;
    while($blogW=mysqli_fetch_array($blogCountA)){
		$count++;
    } ?>
<li><a href="<?php echo SITE_WS_PATH.'/knowledge-base/'.''.str_replace(" ","-",strtolower($blogWs['catP_Name']));?>" class="btn btn-primary hu"><?php echo $blogWs['catP_Name']; ?> ( <?php echo $count; ?> )</a></li>
   
   <?php } 
   
   ?>
</ol>
</div>
</div>
<div class="container">

<div class="col-md-12" >

<!--<ol class="breadcrumb y">
<p class="rblo">OUR RECENT BLOGS</p>
<?php 
/*$blogCount=mysql_query("SELECT catP_Name from tbl_blogcatp where status=1");
while($blogWs=mysql_fetch_array($blogCount)){
	$blogCountA=mysql_query("SELECT cat_name from tbl_blog where cat_name LIKE '%$blogWs[catP_Name]%'");
    $count=0;
    while($blogW=mysql_fetch_array($blogCountA)){
		$count++;
    } ?>
<li><a href="<?php echo SITE_WS_PATH.'/knowledge-base/'.''.str_replace(" ","-",strtolower($blogWs['catP_Name']));?>" class="btn btn-primary hu"><?php echo $blogWs['catP_Name']; ?> ( <?php echo $count; ?> )</a></li>
   <?php } */?>
</ol>-->

<?php
$req = $_SERVER['HTTP_HOST'].''.$_SERVER['REQUEST_URI'];
$exsp = explode("/", $req);
$start =$exsp[1];
$dsdsd = explode("/", $req);
$poison=$dsdsd[2];
$poisonA=explode("?", $poison);
$poisonB=ucwords(str_replace("-"," ",$poisonA[0]));
$start = intval($start);
$pagesize=0;
$order_by=0;
$order_by2=0;
$pagesize = intval($pagesize)==0?$pagesize=55:$pagesize;
//print_r($pagesize); exit;
$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 = 'ASC' : true;
$sql_count = "select count(*) ".$sql; 
//$sql .= "order by $order_by $order_by2 ";
//$sql .= "order by $order_by $order_by2 ";
//$sql .= "limit $start, $pagesize ";
$sql = $columns.$sql;
//print_r($sql);exit();
$result = db_query($sql);
?>
<?php
if($start==0){
  $cnt=0;
}
else{
  $cnt=$start;
}
while($line_raw = mysqli_fetch_array($result)) {
  $cnt++;
@extract($line_raw);

?>
<div class="col-md-6"> 
  <div class="well bn">
      <div class="media">
      	<a class="pull-left" href="<?php echo SITE_WS_PATH.'/knowledge-base/'.$serviceUri=str_replace(" ", "-",strtolower($heading)); ?>">
    		<img class="media-object" src="<?php echo SITE_WS_PATH."/uploaded_files/blog/original/".$blog_banner; ?>" alt="<?php echo $alt; ?>">
  		</a>
  	<div class="media-body">
  	 <ul class="list-inline list-unstyled">
  	 <!--<p class="text-right"><? //echo $post_writer; ?></p>-->
  	
  			
           <?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.'/knowledge-base/'.strtolower(str_replace(" ","-",$value));
    echo "<a href='$dynamicURL' class='btn btn-xs btn-primary'>".$value."</a>";   ?>  
	<?php
	}
	?>
		 
	</ul>
	<h1 class="media-heading hjk"><a style="text-decoration:none;" href="<?php echo SITE_WS_PATH.'/knowledge-base/'.$serviceUri=str_replace(" ", "-",strtolower($heading)); ?>"> <?php echo substr(strip_tags(ucwords($heading)), 0, 38).'...'?></a></h1>
          
          <p><?php echo substr(strip_tags(($line_raw['content'])), 0, 100).'...'; ?></p>
          <p class="readmm"><a href="<?php echo SITE_WS_PATH.'/knowledge-base/'.$serviceUri=str_replace(" ", "-",strtolower($heading));  ?>">Read more <i class="fa fa-angle-right"></i></a></p>
	
	
    </div>
    </div>
  </div>
  </div>
<?php }?>
</div>
<!--<div class="col-lg-3 right-form">
<div class="list-group" style="border-radius: 4px;">
 <ol class="breadcrumb" style="    background: #8e8d8d; color: #fff;  font-size: x-large;">Latest Blog</ol>
  <?php $sql123 = db_query("select heading from tbl_blog where status=1 order by id DESC limit 10");
        while ($ddd = mysqli_fetch_array($sql123)) { ?>
        <a href="<?php echo SITE_WS_PATH.'/knowledge-base/'.$serviceUri=str_replace(" ", "-",strtolower($ddd['heading'])); ?>" class="list-group-item" style="line-height: 2em;"><i class="fa fa-link" aria-hidden="true"></i> <?php echo ucfirst(substr($ddd['heading'], 0, 30)).'...';?></a>  
   <?php } ?>
</div>
</div> -->

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