'.trim(substr(del_line($row['content']),0,250)).'
- -
Danh sách bài viết mới
$num = $db->query("SELECT COUNT(1) FROM (SELECT * FROM posts WHERE type=1) x")->fetchColumn();
$page = $_GET['page'];
$page_max = ceil($num/10);
if(!$page){$page=1;}elseif($page>$page_max){$page=$page_max;}
$start = ($page-1)*10;
$result = $db->query("SELECT * FROM posts WHERE type=1 ORDER BY time DESC LIMIT '$start',10");
foreach($result as $row){
// ==> thân bài viết
// Lấy thể loại
$id_category = $row['category'];
$stmt = $db->prepare("SELECT * FROM categorys WHERE id='$id_category'");
$stmt -> execute();
$category = $stmt->fetch();
// End thể loại
// thumb mô tả
if($row['thumb']){
$thumb = $row['thumb'];
}else{
$thumb = '/images/default/'.substr($row['rwtitle'],0,1).'.png';
}
// đếm bình luận
$id = $row['id'];
$num_cmt[$id] = $db->query("SELECT COUNT(1) FROM (SELECT * FROM comments WHERE posts='$id') x")->fetchColumn();
if($num_cmt[$id]>0){$cmt[$id] = ' '.$num_cmt[$id].' bình luận';}
echo '
';
$stmt = $category = NULL;
// <== thân bài viết
} ?>
1){
if($page>3){echo '1';}
if($page>4){echo '...';}
if(($page-2)>0){echo ''.($page-2).'';}
if(($page-1)>0){echo ''.($page-1).'';}
if($page_max>1){echo ''.$page.'';}
if(($page+1)<=$page_max){echo ''.($page+1).'';}
if(($page+2)<=$page_max){echo ''.($page+2).'';}
if($page<($page_max-3)){echo '...';}
if($page<($page_max-2)){echo ''.$page_max.'';}
}
?>