<form class ="bg-info " action="">
	<div class="form-group row">
			<input class="form-control col-md-5 " type="text" id="key" placeholder="Nhập tiêu đề" name="key">
			<select class="form-control col-md-3 ml-4" name="frtheloai" id="theloai" >
				<option value="">Chọn thể loại</option>
				<?php  
				$result = $quantridata -> theloai();
				while($row = mysqli_fetch_array($result))
				{?>
					<option value="<?php echo $row['idTL'] ?>"><?php echo $row['TenTL'] ?></option>
				<?php }?>
			</select>
	</div>	
	
</form>
<div id="danhsach">
<table class="table table-striped table-bordered table-hover table-responsive-md">
	<thead class="table-info">
	<tr>
		<th>ID</th>
		<th>Tiêu đề bài viết</th>
		<th>Thể loại</th>
		<th>Ngày tạo</th>
		<th>Lượt xem</th>
		<th>Chức năng</th>
	</tr>
	</thead>
	<tbody>
<?php
if(isset($_GET['trang']))
	{
		$trang=$_GET['trang'];
		settype($trang,"int");
	}	
else $trang = 1;
$sotin = 1;
$from = ($trang-1)*$sotin;
$sh = $quantridata -> baiviet();
$sohang = mysqli_num_rows($sh);
$tongtrang = ceil($sohang/$sotin);
$result = $quantridata -> phantrang($from,$sotin);
$tranghientai = $_GET['trang'];
while($row = mysqli_fetch_array($result))
{?>
	<tr>
		<td><?php echo $row['idTin'] ?></td>
		<td width="50%"><?php echo $row['TieuDe'] ?></td>
		<td><?php echo $row['TenTL'] ?></td>
		<td><?php
		$ngay = date_create($row['Ngay']);
		$ngay = date_format($ngay,"d-m-Y");
		 echo $ngay;
		 ?>	
		</td>
		<td><?php echo $row['SoLanXem'] ?></td>
		<td width="15%">
			<a href="quantritueba.php?page=suabai&idtin=<?php echo $row['idTin'] ?>"><i class="fas fa-edit"></i> Sửa</a>
			&ensp; <a class="text-danger" href="quantritueba.php?page=xoabai&idtin=<?php echo $row['idTin'] ?>"><i class="fas fa-trash-alt"></i> Xóa</a>
		</td>
	</tr>

<?php }?>
</tbody>
</table>
<!--  ------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="?page=baiviet&trang=<?php echo ($tranghientai-1) ?>">
		<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="?page=baiviet&trang=<?php echo $i ?>"><?php echo $i ?></a>
	 				</li>
	 			<?php }?>
	 		<?php } else{?>
	 				<li class="page-item active ">
	 				<a class="page-link" href="?page=baiviet&trang=<?php echo $i ?>"><?php echo $i ?></a>
	 				</li>
	 		<?php } ?>	
        <?php } ?>	
 
	<li class="page-item <?php if($tranghientai==$tongtrang) echo "disabled" ?>">
		<a class="page-link" href="?page=baiviet&trang=<?php echo ($tranghientai+1) ?>"><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="?page=baiviet&trang=<?php echo $tongtrang?>"><i class="fas fa-step-forward"></i></a>
	</li>
 </ul>
<!-- ------------------------- -->   	
</div>     	
