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.