include 'function.php';
header('content-type:text/html;charset=utf-8;');
$pdo=new PDO("mysql:host=localhost;dbname=t1","root","");
$stmt=$pdo->prepare("select * from tieba");
$stmt->execute();
$res=$stmt->fetchall();
$rows=count($res);//总的条数
$pagesize=8;
if($rows==0){
$pagenum=0;
}else{
$pagenum=ceil($rows/$pagesize);//分成几页
}
if(isset($_GET['page'])){
$page=$_GET['page'];
if(empty($page)||$page<0||!is_numeric($page)) {
$page=1;
}else{
$page=intval($page);
}
}else{
$page=1;
}
if($page>$pagenum){
$page=$pagenum;
}
$startnum = ($page - 1)*$pagesize;
$display_page=5;
$query = "SELECT * FROM tieba LIMIT $startnum,$pagesize";
$stmt2=$pdo->prepare($query);
$stmt2->execute();
$res2=$stmt2->fetchall(PDO::FETCH_ASSOC);
foreach($res2 as $v){
echo '
}
?>