The perfect page flip function with empty jumps

Source: Internet
Author: User
It can be said that this is the most complete page flip function you have ever seen. the detailed content is explained in the code! SyntaxHighlighter. all (); info & nbsp; | & nbsp; Security & nbsp; | & nbsp

It can be said that this is the most complete page flip function you have ever seen. the detailed content is explained in the code!

// Set the number of entries in the list
$ ListNum = 25;

// Set the start position
If ($ Start_Num = ""){
$ Start_Num = 0;
}

// Set the front flip
$ Begin_Num = $ Start_Num-$ ListNum;
// Set the suffix
$ End_Num = $ Start_Num + $ ListNum;


// Variable used to calculate the number of items during page turning
$ N = 0;

// The initial value of the generated list
$ ArtList = "";

// Connect to the database (ODBC is used in this example )!
$ Conn = ODBC_CONNECT ("DSN", "user", "password ");
$ SQL = "SELECT field FROM table ";
// Well, here all the select statements are available, which is inefficient and exaggerated. However, this is just to demonstrate our central content-turning pages!

$ Result = $ ODBC_DO ($ Conn, $ SQL );

While ($ odbc_fetch_row ($ Result )){
If ($ n <$ Start_Num + $ ListNum & $ n> = $ Start_Num ){
$ Thevalue = ODBC_RESULT ($ Result, "field ");
$ ArtList. = $ n. $ thevalue ."
";
}
$ N ++;
}

// Obtain the start item of the last page
If ($ n % $ ListNum = 0 ){
$ LastPage = $ n-$ ListNum;
} Else {
$ LastPage = $ n-$ n % $ ListNum;
}
// Always have the last page
$ ArtList. ="
| <最前一页  ";






















// Only when Start_Num is greater than 0 can the previous page be available If ($ Start_Num> 0 ){ $ ArtList. = "< <上一页  "; } Else { $ ArtList. = "< <上一页  "; } // If Start_Num is already within the range of the last page, there cannot be a Next page If ($ Start_Num <$ n-$ ListNum ){ $ ArtList. = "next page> "; } Else { $ ArtList. = "next page> "; } // There is always the last page $ ArtList. = "Last Page> | "; Echo $ artList; ?>

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.