php开发_分页
程序员文章站
2022-05-16 08:21:30
...
项目结构:
运行效果:
========================================
conn.php
1 ", str_replace(" ", " ", $content)); 8 return $content; 9 }10 ?>
page.php
1 " . ($totle ? ($firstcount +1) : 0) . "-" . min($firstcount + $displaypg, $totle) . " 条记录,共 $totle 条记录";36 37 //如果只有一页则跳出函数:38 if ($lastpg 首页 ";42 if ($prepg)43 $pagenav .= " 前页 ";44 else45 $pagenav .= " 前页 ";46 if ($nextpg)47 $pagenav .= " 后页 ";48 else49 $pagenav .= " 后页 ";50 $pagenav .= " 尾页 ";51 52 //下拉跳转列表,循环列出所有页码:53 $pagenav .= " 到第 页,共 $lastpg 页";61 }62 63 64 include("conn.php");65 66 $result=mysql_query("SELECT * FROM `test`");67 $total=mysql_num_rows($result);68 //调用pageft(),每页显示10条信息(使用默认的20时,可以省略此参数),使用本页URL(默认,所以省略掉)。69 _PAGEFT($total,5);70 echo $pagenav;71 72 $result=mysql_query("SELECT * FROM `test` limit $firstcount,$displaypg ");73 while($row=mysql_fetch_array($result)){74 75 echo "
".$row[name]." | ".$row[sex];76 77 }78 ?>
list.php
1 $pagesize){19 if($pageval上一页 下一页";22 }23 $SQL="SELECT * FROM `test` limit $page $pagesize ";24 $query=mysql_query($SQL);25 while($row=mysql_fetch_array($query)){26 27 echo "
".$row[name]." | ".$row[sex];28 29 }30 ?>
分页公式:(当前页数-1)*每页条数,每页条数
sql语句:select * from test_table limit ($page-1)*$pageSize,$pageSize;