cn=@odbc_connect;if{$error=”连接数据库出错”;$this->getMess;}
}function
getDo{//从表中查询数据$this->d=@odbc_do;if{$error=”查询时发生了小错误……”;$this->getMess;}return
$this->d;}function
getTotal{$this->sql=$sql;$dT=$this->getDo;//求总数的游标$this->total=odbc_result;//这里为何不能$this->d呢?return
$this->total; }function
getList{$this->s=$sql;$this->onepage=$onepage;$this->page=$page;$this->dList=$this->getDo;//连接表的游标$this->pages=ceil($this->total/$this->onepage);if
$this->pages++; //不能取到第0页if $this->page=1;$this->fre =
$this->page-1;//将显示的页数$this->nxt = $this->page+1;
$this->nums=*$this->onepage;
//if{//for($this->i=0;$this->igetNums();odbc_fetch_row,$this->i++);//同上//}//$this->i=0;//为何这部分不能封装?return
$this->dList; }function
getFanye(){$str=””;if$str.=”首页fre.”>
前页”;else$str.=”首页
前页”;if($this->pagepages)$str.=”nxt.”>
后页”;else$str.=”
后页 “;if($this->page!=$this->pages)$str.=”pages.”>
尾页”;else$str.=”
尾页
“;$str.=”共”.$this->pages.”页”;$str.=”您正浏览第”.$this->page.”页”;return
$str;}function getNums(){return $this->nums;}function
getOnepage(){//每页实际条数return $this->onepage;}function
getI(){return $this->i;}function getPage(){return
$this->page;}function getMess{//定制消息echo”$error”;exit;}}$pg=new
Pages();$pg->getConnect(“lei”,”sa”,”star”);$pg->getTotal as total
from xs”);//连学生表求总数$pg->getList(“select xs_name from xs order
by xs_id”,8,$page);
if{for($i=0;$igetNums();odbc_fetch_row;//同上}$i=0;while(odbc_fetch_row{$name=odbc_result($pg->dList,”xs_name”);echo
$name.”
“;if){//跳出循环break;}$i++;}echo$pg->getFanye();?>

发表评论

电子邮件地址不会被公开。 必填项已用*标注