Quick look and Practical PHP + JS paging! Similar to Baidu

Source: Internet
Author: User
Urgent! Find a nice and Practical PHP + JS page! The effect is similar to that of Baidu! Find a nice and Practical PHP + JS page! The effect is similar to that of Baidu! & Nbsp; effect: 12345678910 on the next page? When the page is not the first page, it is displayed as follows: the first page is 12345678910! Find a nice and Practical PHP + JS page! Similar to Baidu
Urgent! Find a nice and Practical PHP + JS page! The effect is similar to that of Baidu!

The effect is as follows:

1 2 3 4 5 6 7 8 9 10 What is the total number of next pages? Page

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

Previous Page 1 2 3 4 5 6 7 8 9 10 What is the total number of next pages? Page

Use "Another color indicates which page is currently displayed"

This paging code can be used together with the MYSQL database to achieve paging effects like Baidu!

I'm a newbie. I know how to get started. please help me! 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. = "homepage";} else {$ strPage. = "homepage";} if ($ start> 0) {$ strPage. = "previous page";} if ($ start + $ limit <$ total) {$ strPage. = "next page";} if ($ start + $ limit <$ total) {$ strPage. = "Last page";} else {$ strPage. = "Last page";} return $ strPage ;}
------ Solution --------------------
Why JS?
------ Solution --------------------
$ BaseUrl is the basic url of the page, such as index. php? M = table & a = list
$ Total is the total number of records to be paged. this is used to calculate the number of pages.
$ Start indicates the number of records starting from the current page.
$ Limit is the number of items displayed on each page. this can be a constant.
$ Parm is an additional parameter. for example, if you add search = 'new' to $ baseUrl, you can add it here to append it to the url.
------ Solution --------------------
Learning.

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.