$pagesize = 2; The number of records displayed on a page
$con = Odbc_connect ("Access_test", "" "," "", Sql_cur_use_odbc) or Die ("Cannot connect to ODBC data source Access_test"); Connect an ODBC data source
$sql = "SELECT count (*) as total from Test"; Get Total Records SQL statement
$rst = Odbc_exec ($con, $sql) or Die ("error $sql query"); Execute get Total records SQL statement
$recordcount = Odbc_result ($rst, 1); Get the total number of records, which can also be used here $recordcount = Odbc_result ($rst, "totals");
Odbc_free_result ($rst); Freeing resources
$pagecount = Bcdiv ($recordcount + $pagesize-1, $pagesize, 0); Figure out the total number of pages
if (!isset ($page)) $page = 1; If no page numbers are specified, the default is to show the first page
if ($page <1) $page = 1; If the page number is smaller than 1, the first page is displayed
if ($page > $pagecount) $page = $pagecount; If page numbers are larger than the total number of pages, the last page is displayed
if ($page >0) {//page number is greater than 0, indicating data
Echo ' >> paging ';
Echo ' Home ';
if ($page >1) {
Echo ' front page ';
}
else{
Echo ' front page ';
}
if ($page < $pagecount) {
Echo ' Back Page ';
}
else{
Echo ' Back Page ';
}
Echo ' last ';
Echo ' page: '. $page. '/' . $pagecount. ' Page ';
Echo $pagesize. ' Bar/page ';
Echo ' Total '. $recordcount. ' article ';
$sql = "SELECT * from Test"; Get data SQL statement
$rst = Odbc_exec ($con, $sql) or Die ("error $sql query"); Execute GET Data SQL statement
$fieldcount = Odbc_num_fields ($rst); Total number of fields obtained
Echo '
'; Echo '
'; for ($i =1; $i <= $fieldcount; $i + +) {echo '
| . Odbc_field_name ($rst, $i). ' | '; Show $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); Freeing resources
}
else{
echo "No data";
}
Odbc_close ($con); Close the connection and release the resource
?>
http://www.bkjia.com/PHPjc/316761.html www.bkjia.com true http://www.bkjia.com/PHPjc/316761.html techarticle $pagesize = 2;//page shows the number of records $con = Odbc_connect (access_test,,, Sql_cur_use_odbc) or die (Cannot connect to ODBC data source access_test); Connect an ODBC data source $sql = Select Co ...