$pagesize = 2; //The 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 an ODBC data source
$sql = "select count(*) as total from test"; //Get the total number of records SQL statement
$rst = odbc_exec($con,$sql) or die("$sql Query error"); //Execute the SQL statement to get the total number of records
$recordcount = odbc_result($rst,1); //Get the total number of records, you can also use $recordcount = odbc_result($rst,"total") here ;
odbc_free_result($rst); //Release resources
$pagecount = bcdiv($recordcount+$pagesize-1,$pagesize,0); //Calculate the total number of pages
if(!isset($page)) $page = 1; //If no page number is specified, the default is to display the first page
if($page<1) $page = 1; //If the page number is greater than 1 If the page number is small, the first page will be displayed
if($page>$pagecount) $page = $pagecount; //If the page number is larger than the total number of pages, the last page will be displayed
if($page> 0){ //The page number is larger than 0, indicating that there is data
echo '>> paging';
echo 'Home page ';
if($page>1){
echo ' ';
}
else{
echo 'Previous page';
}
if($page<$pagecount){
echo '< ;a href="' . $PHP_SELF . '?page='. ($page+1) . '">Next page ';
}
else{
echo ' Next page';
}
echo 'Last page ';
echo 'Page: ' . $page . '/' . $pagecount . 'Page';
echo $pagesize . 'Bar/page';
echo 'Total' . $recordcount . 'Bar';
$sql = "select * from test"; //Get data SQL statement
$rst = odbc_exec($con,$sql) or die("$sql query error"); //Execute to get data SQL statement
$fieldcount = odbc_num_fields($rst); //Get the total number of fields
echo '
' .odbc_field_name($rst, $i) . ' | '; //Display $i field name|
---|---|
'; | ' . ; ; 🎜>} else{ echo "No data"; } odbc_close($con); //Close the connection and release resources ?>
Related labels:
source:php.cn
Previous article:PHP and XML: Using expat function (2)_PHP tutorial
Next article:PHP and XML: Using the expat function (3)_PHP Tutorial
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Latest Issues
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
|