$sql1 = "select count(*) from daohang where aid={$id}";
$result1 = MYSQLi_query($conn,$sql1);
$page = mysqli_fetch_row($result1);// 信息总数
$page = $page[0];
$pagesize=4;// 每页显示数量
$num = ceil($page/$pagesize);
$pagenum = empty($_GET["pagenum"])?1:$_GET["pagenum"];// 第几页
$sql = "select a.id,a.url,a.title from daohang as a where aid ={$id} limit ".($pagenum-1)*$pagesize.",".$pagesize;
$result =mysqli_query($conn,$sql);
if($result){
while ($row = mysqli_fetch_assoc($result)) {
echo "<div class='nav-1 col-md-5'>";
echo "<a class='link' target='_blank' href=".$row['url'].">".$row['title']."
</a></div>";
}
}
echo "<div style="clear:both;"></div><div class="pagess"><ul class="pagination">";
echo "<li><a href='?pagenum=1'>首页</a></li>";
for($i=1;$i<$num+1;$i++){
echo "<li><a href='?pagenum=".$i."'>第".$i."页</a></li>";
}
echo "<li><a href='?pagenum=".$num."'>末页</a></li>";
echo "<li><a>共".$num."页</a></li>";
echo "</ul></div>";
来源:http://www.cuteur.cn/post/647.html