<? Php
$ 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;
?>
<Table>
<Tr>
<Td>
Total <? Php echo $ pagecount?> Page
<? Php if ($ pages! = 1) echo "<a href = show. php3? Pages = 1> ";?> Homepage <? Php if ($ pages! = 1) echo "</a>";?>
<? Php if ($ pages! = 1) echo "<a href = show. php3? Pages = ". $ fpages."> ";?> Previous Page <? Php if ($ pages! = 1) echo "</a>";?>
<? Php if ($ pages! = $ Pagecount) echo "<a href = show. php3? Pages = ". $ bpages."> ";?> Back page <? Php if ($ pages! = $ Pagecount) echo "</a>" ;?> <? Php if ($ pages! = $ Pagecount) echo "<a href = show. php3? Pages = ". $ pagecount."> ";?>
Last page <? Php if ($ pages! = $ Pagecount) echo "</a>" ;?>
</Td>
</Tr> </table>
<? Php
$ 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 )){
};
?>
<? Php
// 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]