odbc| Page | Original <!--two springs. NET-->
?
Class pages{
var $cn; Connecting database Cursors
var $d; Cursors that connect data tables
var $result; Results
var $dsn; DSN source
var $user; User name
var $pass; Password
var $total; Total Records
var $pages; Total pages
var $onepage; Number of bars per page
var $page; Current page
var $fre; Previous page
var $net; Next page
var $i; Control each page display
function Getdo ($sql) {//query data from tables
$this->d= @odbc_do ($this->cn, $sql);
if (! $this->d) {
$error = "A small error occurred while querying ...";
$this->getmess ($error);
}
return $this->d;
}
function Gettotal ($sql) {
$this->sql= $sql;
$dT = $this->getdo ($this->sql); Number of cursors to be evaluated
$this->total=odbc_result ($dT, ' total '); why can't $this->d here?
return $this->total;
}
function GetList ($sql, $onepage, $page) {
$this->s= $sql;
$this->onepage= $onepage;
$this->page= $page;
$this->dlist= $this->getdo ($this->s); cursors that connect tables
$this->pages=ceil ($this->total/$this->onepage);
if ($this->pages==0)
$this->pages++; Cannot take to page No. 0
if (!isset ($this->page))
$this->page=1;
$this->fre = $this->page-1; The number of pages to display
$this->nxt = $this->page+1;
$this->nums= ($this->page-1) * $this->onepage;
if ($this->nums!=0) {
For ($this->i=0; $this->i< $pg->getnums (); Odbc_fetch_row ($this->dd), $this->i++);/ibid.
//}
$this->i=0;//Why is this part not encapsulated?
return $this->dlist;
}
function Getfanye () {
$str = "";
if ($this->page!=1)
$str. = "<a href=". $PHP _self. "? page=1> home </a><a href= ". $PHP _self."? Page= ". $this->fre." > front page </a> ";
Else
$str. = "<font color=999999> first page </font>";
if ($this->page< $this->pages)
$str. = "<a href=". $PHP _self. "? Page= ". $this->nxt." > Back Page </a> ";
Else
$str. = "<font color=999999> after page </font>";
if ($this->page!= $this->pages)
$str. = "<a href=". $PHP _self. "? Page= ". $this->pages." > Last </a> ";
Else
$str. = "<font color=999999> last </font>";
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.