<?php 
	if(isset($_GET['idtl']))
	{
	$idtl=$_GET['idtl'];
	settype($idtl,"int");
	}
	else $idtl = 1;	
	if(isset($_GET['trang']))
	{
		$trang=$_GET['trang'];
		settype($trang,"int");
	} else $trang = 1;
	if($trang==0) $trang = 1;
?>
<?php 
	$theloai = $homedata -> theloaikd($idtl);
	$tentheloai = mysqli_fetch_array($theloai);
 ?>
 <div class="khung">
<nav aria-label="breadcrumb">
  <ol class="breadcrumb">
    <li class="breadcrumb-item"><a href="#"><i class="fas fa-home"></i></a></li>
    <li class="breadcrumb-item active" aria-current="page">Category</li>
    <li class="breadcrumb-item active" aria-current="page"><?php echo $tentheloai['TenTL'] ?></li>
  </ol>
</nav>
<div class="row mt-3">	
<div class="col-md-12 ">	
<?php 
	$sotin = 10;
	$from = ($trang-1)*$sotin;
	$result = $homedata -> theloai_phantrang($idtl,$from,$sotin);
	$sh = $homedata -> theloai($idtl);
	$sh1 = $homedata -> theloaikd($idtl);
	$result2 = mysqli_fetch_array($sh1);
	$tlkd = $result2['TenTL_KhongDau'];
	$sohang = mysqli_num_rows($sh);
	$tongtrang = ceil($sohang/$sotin);
	$tranghientai = $_GET['trang'];
	while($row = mysqli_fetch_array($result))
	{?>	<div class="border-bottom mt-2 mb-2">
			<h6><a class="mauxanh" href="bai-viet/<?php echo $row['TieuDe_KhongDau'] ?>-<?php echo $row['idTin'] ?>.html"><?php echo $row['TieuDe']?>
			</a></h6>
			<i>
				<i class="far fa-clock"></i>&nbsp;<span><?php 
					$ngay = date_create($row['Ngay']) ;
					$ngay = date_format($ngay,"d/m/Y");
					echo $ngay
				?>
			    </span>&ensp;
				<span class="fas fa-chart-bar " style="color:#9fbad6">&nbsp;<?php echo $row['SoLanXem'];?></span>
			</i>

		</div>
 <?php } ?> 
<!--  ------Pagination------------ -->
<ul class="pagination justify-content-center ">
	<li class="page-item <?php if($tranghientai==1) echo "disabled" ?>">
		<a class="page-link" href="chuyen-muc/<?php echo "$tlkd-$idtl-1"?>.html">
		<i class="fas fa-step-backward"></i></a>
	</li>
	<li class="page-item <?php if($tranghientai==1) echo "disabled" ?>">
		<a class="page-link" href="chuyen-muc/<?php echo "$tlkd-$idtl-".($tranghientai-1) ?>.html">
		<i class="fas fa-caret-square-left"></i></a>
	</li>
	 	<?php for($i=1;$i<=$tongtrang;$i++) {?>
	 		<?php if($i != $tranghientai){?> 
	 			<?php if($i>$tranghientai-5 && $i< $tranghientai+5) {?>
	 				<li class="page-item <?php if($i==$tranghientai) echo "active" ?>">
	 				<a class="page-link" href="chuyen-muc/<?php echo "$tlkd-$idtl-$i" ?>.html"><?php echo $i ?></a>
	 				</li>
	 			<?php }?>
	 		<?php } else{?>
	 				<li class="page-item active ">
	 				<a class="page-link" href="chuyen-muc/<?php echo "$tlkd-$idtl-$i" ?>.html"><?php echo $i ?></a>
	 				</li>
	 		<?php } ?>	
        <?php } ?>	
 
	<li class="page-item <?php if($tranghientai==$tongtrang) echo "disabled" ?>">
		<a class="page-link" href="chuyen-muc/<?php echo "$tlkd-$idtl-".($tranghientai+1) ?>.html"><i class="fas fa-caret-square-right"></i></a>
	</li>
	<li class="page-item <?php if($tranghientai==$tongtrang) echo "disabled" ?>">
		<a class="page-link" href="chuyen-muc/<?php echo "$tlkd-$idtl-$tongtrang"?>.html"><i class="fas fa-step-forward"></i></a>
	</li>
 </ul>
<!-- ------------------------- -->
 </div> 
 
</div>
</div>

