PHP Paging code (next previous page)

Source: Internet
Author: User
  code is as follows copy code
$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>";
    }
   }
  }
  


  /pagination code two
   

  code is as follows copy code
$pernumber =10 ; The number of records displayed per page
  $page =$_get[' page '];//Get current page value
  $count =mysql tutorial _query ("SELECT count (*) from user"); Get the total number of records
  $rs =mysql_fetch_array ($count);
  $totalnumber = $rs [0];
  $totalpage =ceil ($totalnumber/$pernumber);//Calculate Total pages
 if (!isset ($page)) {
  $page =1;
& nbsp;} If there are no values, the assignment 1
  $startcount = ($page-1) * $PERNUMBER;//page start, calculate the start record based on this method
  $result =mysql_query (" SELECT * from user limit $startcount, $pernumber "); Based on the previous calculation, the number of records and records started
 while ($row =mysql_fetch_array ($result)) {
  echo "user_id:". $row [0]. " <br> ";
  EchoUsername: ". $row [1]." <br> "; Display the contents of the Database tutorial
 }
 if ($page!= 1) {//Page not equal to 1
 ?>
 <a href= ' fenye.php?page=<? PHP echo $page-1;? > > Prev </a> <!--display previous page
 <?php
 }
 for ($i =1; $i <= $totalpage; $i + + { //Loop Display page
 ?>
 <a href= "fenye.php?page=<?php echo $i;? > "><?php echo $i;? ></a>
 <?php
 }
 if ($page < $totalpage) {//If page is less than the total number of pages, show next page link
 ?
 <a href= "fenye.php?page=<?php echo $page + 1;? > > Next page </a>
 <?php
 
 

?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.