Use ODBC pagination

Source: Internet
Author: User
Use the ODBC paging display, read the ODBC paging display ,? Php $ pagesize = 3; // set the number of records displayed on each page // calculate the total number of records $ rs_num = selectcount (*) asidfromtable; $ rs_num = odbc_exec ($ conn_id, $ rs_num ); $ rs_num = odbc

$ Pagesize = 3; // you can specify the number of entries displayed on each page.

// Calculate the total number of records
$ Rs_num = "select count (*) as id from table ";
$ Rs_num = odbc_exec ($ conn_id, $ rs_num );
$ Rs_num = odbc_result ($ rs_num, "id ");

// Calculate the total number of pages
$ Pagecount = $ rs_num/$ pagesize;
$ Pagecount1 = intval ($ pagecount); // set the total number of pages
$ Compare = $ pagecount-$ pagecount1;
Switch ($ compare ){
Case "0 ":
$ Pagecount = $ pagecount1; // total number of pages
Break;
Default:
$ Pagecount1 ++;
$ Pagecount = $ pagecount1; // total number of pages
Break;
};
If ($ pagecount = 0) $ pagecount ++;


$ Fpages = $ pages-1;
$ Bpages = $ pages + 1;



?>




Total Page
Homepage
Previous Page
Back page
Last page

$ Firstshow = ($ pages-1) * $ pagesize + 1; // you can specify the first record on each page.

// Find the record number of the first record
$ Query_string = "SELECT * FROM table Order By id DESC ";
$ Query_string = odbc_exec ($ conn_id, $ query_string );
Odbc_fetch_into ($ query_string, $ firstshow, & $ idarea );
$ Idsql = $ idarea [0];

// Locate and find
If ($ pages = $ pagecount ){
$ Rs = "SELECT * FROM table where id <= '". $ idsql. "'Order By id DESC ";
} Else {
$ Rs = "SELECT Top". $ pagesize. "* FROM table where id <= '". $ idsql. "'Order By id DESC ";
};

$ Rs = odbc_exec ($ conn_id, $ rs );

// Display records
While (odbc_fetch_row ($ rs )){



};
?>

// Close the connection
Odbc_close ($ conn_id );
?>


[This article is copyrighted by the author and osuo. if you need to reprint it, please indicate the author and its source]

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.