<?php require('includes/cmain.inc.php'); ?>
<?php include('header.php'); ?>

<div class="home-banner">
<ul class="home_slider cf mhide">    
<?php
$url = explode('/', rtrim($_SERVER["REQUEST_URI"],"/"));
$urls= SITE_WS_PATH.'/'.$url[1];
//'<pre>'; print_r($urls) ; '<pre>';
$blogurl = ucwords(str_replace('-', ' ',$url[1]));
if($urls=='https://metalstamping-dies.com/about-us')
{
?><img src="<?php echo SITE_WS_PATH; ?>/images/slider/About-us.webp" alt="about us"/>"<?php
}
elseif($urls=='https://www.metalstamping-dies.com/knowledge-base')
{
?> <img src="<?php echo SITE_WS_PATH; ?>/images/slider/Blog.webp" alt="Blog"/>"<?php    
}
elseif($urls=='https://metalstamping-dies.com/tooling')
{
?> <img src="<?php echo SITE_WS_PATH; ?>/images/slider/Tooling.webp" alt="Tooling"/>"<?php    
}
elseif($urls=='https://metalstamping-dies.com/stamping')
{
?> <img src="<?php echo SITE_WS_PATH; ?>/images/slider/Stamping.webp" alt="Stamping"/>"<?php    
}
elseif($urls=='https://metalstamping-dies.com/die-designing')
{
?> <img src="<?php echo SITE_WS_PATH; ?>/images/slider/Die-Designing.webp" alt="Die Designing"/>"<?php    
}
elseif($urls=='https://metalstamping-dies.com/contact-us')
{
?> <img src="<?php echo SITE_WS_PATH; ?>/images/slider/Contact-Us.webp" alt="Contact Us"/>"<?php    
}
?>
</ul>
</div>
<?php
//------------ start of knowledge base------------------
if($blogurl=='Knowledge Base'){?>
<div id="content">
<br />
<div class="container">
<div class="col-md-12" >

<ol class="breadcrumb y">
<p class="rblo">OUR RECENT BLOGS</p>
<?php 
$blogCount=mysqli_query($conn,"SELECT catP_Name from tbl_blogcatp where status=1");
while($blogWs=mysqli_fetch_array($blogCount)){
	$blogCountA=mysqli_query($conn,"SELECT cat_name from tbl_blog where cat_name LIKE '%$blogWs[catP_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>

<?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=5:$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 = mysqli_query($conn,$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="#">
    		<img class="media-object" src="<?php echo SITE_WS_PATH."/uploaded_files/blog/original/".$blog_banner; ?>">
  		</a>
  	<div class="media-body">
  	 <ul class="list-inline list-unstyled">
  	 <p class="text-right"><?php echo $post_writer; ?></p>
  	
  			
           <?php $fetchSQL = mysqli_fetch_array(mysqli_query($conn,"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 ucfirst($heading); ?></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 = mysqli_query($conn,"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 }else{?>
<?php include('index_banner.php'); ?>
<div class="welcome-sec">
<div class="container cf">

<div class="welcome-img">
<?php include('right_menu.php'); ?>
</div>
<?php
$url = explode('/', rtrim($_SERVER["REQUEST_URI"],"/")); 
$count=count($url);
$menuurl = ucwords(str_replace('-', ' ',$url[$count-1]));
$sqlmenu=mysql_query("SELECT * FROM `the_menu`  where name='".trim($menuurl)."' and status=1");
$menu=mysql_fetch_array($sqlmenu);
$menuother= $menu['name'];
$menucontent= $menu['content'];

?>

<p><?php echo $menucontent; ?></p>
</div>
</div>
<?php } ?>
</main>
</div>
</div>
<?php include('footer.php'); ?>