Several classic PHP page-paging programs (1/4)

Source: Internet
Author: User

function _pageft ($totle, $displaypg = $url = ') {

Global $page, $firstcount, $pagenav, $_server;

$globals ["displaypg"] = $DISPLAYPG;

if (! $page)
$page = 1;
if (! $url) {
$url = $_server["Request_uri"];
}

  //url Analysis:
   $parse _url = Parse_url ($url);
   $url _query = $parse _url["Query "]; Query string
  if ($url _query) {
    $url _query = ereg_replace ("(^|&) page=$" for individual removal of URLs Page "," ", $url _query);
    $url = str_replace ($parse _url["Query"), $url _query, $url);
   if ($url _query)
     $url. = "&page";
   else
     $url. = "page";
  } else {
    $url. = "? page";
  }
   $lastpg = ceil ($totle /$DISPLAYPG); Last page, is also the total number of pages
   $page = min ($lastpg, $page);
   $PREPG = $page-1;//prev
  $ NEXTPG = ($page = = $LASTPG 0: $page + 1); Next page
   $firstcount = ($page-1) * $DISPLAYPG;

To start the pager bar code:
$pagenav = "Show <b>". ($totle? ($firstcount + 1): 0). "</b>-<b>". Min ($firstcount + $DISPLAYPG, $totle). "</b> Records, a total of $totle records";

Home 1 2 3 4 last page

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.