$pagesize = 3;//Sets the number of display per 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 Total Pages
$pagecount = $rs _num/$pagesize;
$pagecount 1 = intval ($pagecount);//Total number of pages rounded
$compare = $pagecount-$pagecount 1;
Switch ($compare) {
Case "0":
$pagecount = Total number of pages $pagecount 1;//
Break
Default:
$pagecount 1++;
$pagecount = Total number of pages $pagecount 1;//
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>";? > Home <?php if ($pages!= 1) echo "</a>"?>
<?php if ($pages!= 1) echo "<a href=show.php3?pages=". $fpages. " >?> Front 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 <?php if ($pages!= $pagecount) echo "</a>";?>
</td>
</tr></table>
<?php
$firstshow = ($pages-1) * $pagesize +1;//determines the first record of 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];
Locating lookup
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);
Show Records
while (Odbc_fetch_row ($rs)) {
};
?>
<?php
Close connection
Odbc_close ($conn _id);
?>
"This article copyright belongs to the author and the Osso net jointly owns, if needs to reprint, please indicate the author and the origin"
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