-
-
//定每页显示多少条
- //count(*)查询总条数
- //计算总页数ceil()
- //判断$_GET 并赋值当前页数
- //mysql查询 limit (当前页数-1)*每页条数,每页条数
- //如果总条数不为空,进行循环mysql_fetch_array()
- //$_SERVER['PHP_SELF']
- //上一页?page=当前页-1
- //下一页?page=当前页+1
- //edit: bbs.it-home.org
-
include("conn.php");
- $perpagenum = 3;
- $total = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM message"));
- $Total = $total[0];
- $Totalpage =ceil($Total/$perpagenum);
if(!isset($_GET['page'])||!intval($_GET['page'])||$_GET['page']>$Totalpage){
- $page = 1;
- }else{
- $page = $_GET['page'];
- }
$start = ($page-1)*$perpagenum;
- $sql = "SELECT * FROM message ORDER BY id DESC LIMIT $start,$perpagenum";
- $result = mysql_query($sql);
- $contents = mysql_fetch_array($result);
- ?>
-
if($total){
- do{
- $user = $contents['user'];
- $contact = $contents['contact'];
- $content = $contents['content'];
- $date = $contents['date'];
?>
昵称:
|
|
发表于:
|
-
|
-
-
}
- //php分页开始
- while($contents=mysql_fetch_array($result));
- $per = $page-1;
- $next= $page+1;
- echo "共有".$Total."条留言,每页".$perpagenum."条,共".$page."/".$Totalpage."页。";
- if($page!=1){
- echo "首页".
- "上一页";
- }
- if($page!=$Totalpage){
- echo "下一页";
- echo "尾页";
- }
- ?>
-
}
- ?>
-
-
复制代码
|
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31