Quick-Looking practical php+js pagination! Similar effect Baidu

Source: Internet
Author: User
Tokyu Find a good-looking and useful PHP+JS page! Similar effect Baidu
Hurry up! Find a good-looking and useful PHP+JS page! Similar effect Baidu!

The effect is as follows:

1 2 3 4 5 6 7 8 9 10 next page total? Page

When it is not the first page, it is displayed as follows:

Prev 1 2 3 4 5 6 7 8 9 10 next total? Page

Which, with "Another color marks out which page is currently displayed"

This paging code can be used with MySQL database connection, to achieve like Baidu's paging effect!

Younger brother is a novice, all do know how to start, please big Brother to help! Thank you!

------Solution--------------------
PHP Code
function _setpage ($BASEURL, $total, $start, $limit, $parm = "") {if ($total! = 0) $pages = $total/$limit;   else $pages = 0;   if (empty ($start)) $start = 0;      if (empty ($limit)) $limit = 20;   if ($start > $total) $start = $total-$limit;   if ($start <0) $start = 0;   if ($limit <0) $limit = 0;      if ($limit >100) $limit = 100;   $start = $start-$top;   $showpage = 10;   $currentpage = $start/$limit;      if ($currentpage <5) {$pageno = 0;   $i = 0;     } else{if ($currentpage +10 > $total/$limit) {$pageno = $currentpage-5;     }else{$pageno = $currentpage-5;   } $i = $pageno * $LIMIT;   } if ($total ==0) $currentpage =-1; $strPage = "Total [". ($currentpage + 1). "/" . Ceil ($pages).   "] page";   $page = 0;   $strPage. = "";        if ($start/$limit > $showpage) {$tmp = ($pageno-1) * $LIMIT;   $strPage. = "<<"; } while ($i < $total) {if ($start/$limit = = $pageno) {$strPage. = "".      ($pageno + 1). "";    } else {    $strPage. = "".      ($pageno + 1). "";      } $pageno + +;      $page + +;      $i + = $limit;        if ($page > $showpage) {$strPage. = ">>";      Break    }} if ($start >0) {$strPage. = "Home";    }else{$strPage. = "Home";    } if ($start >0) {$strPage. = "Previous page";    } if ($start + $limit < $total) {$strPage. = "Next page";    } if ($start + $limit < $total) {$strPage. = "Last";    }else{$strPage. = "Last"; } return $strPage;}
------Solution--------------------
Why JS?
------Solution--------------------
$BASEURL a basic URL for the page, such as Index.php?m=table&a=list
$total is the total number of records that you want to page, to calculate how many pages you have.
$start the number of record bars to start for the current page.
$limit the number of bars to display per page, this can be set as a constant.
$parm For additional parameters, such as when you add a search= ' news ' based on $baseurl, you can add it here to append to the URL.
------Solution--------------------
Learn.
  • 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.