文章这里为你提供一二款分页代码,里面有一款超简洁代码的分页程序,如果你正是php初学者这款分页代码很不错,代码如下:
- $page_total = $num/$pagesize_wish;
- $page_total_int = (int)$page_total;
- if($page_total!=$page_total_int) $page_total = $page_total_int+1;
- for($i=1;$i<=$page_total;$i++){
- if($i==$_get['w']){
- print " <strong>".$i."</strong> ";
- }else{
- if(!$_get['w']){
- if($i==1){
- print " <strong>".$i."</strong> ";
- }else{
- print "<a href="../?w=$i"> $i </a>";
- }
- }else{
- print "<a href="../?w=$i"> $i </a>";
- }
- }
- }
-
-
-
- $pernumber=10;
- $page=$_get['page'];
- $count=mysql教程_query("select count(*) from user");
- $rs=mysql_fetch_array($count);
- $totalnumber=$rs[0];
- $totalpage=ceil($totalnumber/$pernumber);
- if (!isset($page)) {
- $page=1;
- }
- $startcount=($page-1)*$pernumber;
- $result=mysql_query("select * from user limit $startcount,$pernumber");
- while ($row=mysql_fetch_array($result)) {
- echo "user_id:".$row[0]."<br>";
- echo "username:".$row[1]."<br>";
- }
- if ($page != 1) {
- ?>
- <a href="fenye.php?page=<?php echo $page - 1;?>">上一页</a> <!--显示上一页-->
- <?php
- }
- for ($i=1;$i<=$totalpage;$i++) {
- ?>
- <a href="fenye.php?page=<?php echo $i;?>"><?php echo $i ;?></a>
- <?php
- }
- if ($page<$totalpage) {
- ?>
- <a href="fenye.php?page=<?php echo $page + 1;?>">下一页</a>
- <?php
- }
-
- ?>
|