Use PHP to display ODBC data by page. $ Pagesize2; number of records displayed on one page $ conodbc_connect (access_test, SQL _CUR_USE_ODBC) ordie (unable to connect to ODBC data source access_test); connect to an ODBC data source $ sqlselectco $ pagesize = 2; // number of records displayed on one page
$ Con = odbc_connect ("access_test", "", "", SQL _CUR_USE_ODBC) or die ("unable to connect to ODBC data source access_test"); // connect to an ODBC data source
$ SQL = "select count (*) as total from test"; // obtain the total number of records SQL statement
$ Rst = odbc_exec ($ con, $ SQL) or die ("$ SQL query error"); // execute an SQL statement that retrieves the total number of records
$ Recordcount = odbc_result ($ rst, 1); // you can use $ recordcount = odbc_result ($ rst, "total") to obtain the total number of records ");
Odbc_free_result ($ rst); // release resources
$ Pagecount = bcp ($ recordcount + $ pagesize-1, $ pagesize, 0); // calculate the total number of pages
If (! Isset ($ page) $ page = 1; // if no page number is specified, the first page is displayed by default.
If ($ page <1) $ page = 1; // if the page number is smaller than 1, the first page is displayed.
If ($ page> $ pagecount) $ page = $ pagecount; // if the page number is larger than the total page number, the last page is displayed.
If ($ page> 0) {// The page number is greater than 0, indicating that data exists.
Echo '> pagination ';
Echo 'homepage ';
If ($ page> 1 ){
Echo 'previous page ';
}
Else {
Echo 'previous page ';
}
If ($ page <$ pagecount ){
Echo 'back page ';
}
Else {
Echo 'back page ';
}
Echo 'Last page ';
Echo 'Page Times: '. $ page.'/'. $ pagecount.' page ';
Echo $ pagesize. 'entries/page ';
Echo 'total'. $ recordcount. 'barri ';
$ SQL = "select * from test"; // SQL statement for retrieving data
$ Rst = odbc_exec ($ con, $ SQL) or die ("$ SQL query error"); // execute an SQL statement to obtain data
$ Fieldcount = odbc_num_fields ($ rst); // retrieves the total number of fields
Echo'
';Echo'
';For ($ I = 1; $ I <= $ fieldcount; $ I ++ ){Echo'
'. Odbc_field_name ($ rst, $ I ).' | '; // Display the $ I field name}Echo'
';$ Rowi = ($ page-1) * $ pagesize + 1;For ($ I = 0; $ I <$ pagesize; $ I ++ ){Echo'
';If ($ rowi> $ recordcount ){For ($ j = 0; $ j <$ fieldcount; $ j ++ ){Echo'
| ';}}Else {Odbc_fetch_into ($ rst, $ rowi, & $ row );For ($ j = 0; $ j <$ fieldcount; $ j ++ ){$ Field = $ row [$ j];If ($ field = '') $ field = '';Echo'
'. $ Field .' | ';}$ Rowi = $ rowi + 1;}Echo'
';}Echo'
';
Odbc_free_result ($ rst); // release resources
}
Else {
Echo "no data ";
}
Odbc_close ($ con); // close the connection and release resources
?>
Records = 2; // number of records displayed on one page $ con = odbc_connect (access_test, SQL _CUR_USE_ODBC) or die (unable to connect to the ODBC data source access_test ); // connect an ODBC data source $ SQL = select co...