寧몸odbc젯mssql롸女돨잚
2018-09-07 12:36
-->
<?
class Pages{
var $cn;//젯쌈鑒앴욋踏깃
var $d;//젯쌈鑒앴깊돨踏깃
var $result;//써벎
var $dsn;//dsn都
var $user;//痰빵츰
var $pass;//쵱쯤
var $total;//션쩌悧鑒
var $pages;//悧女鑒
var $onepage;//첼女係鑒
var $page;//뎠품女
var $net;//苟寧女
var $i;//왠齡첼女鞫刻
function getConnect($dsn,$user,$pass){
$this->cn=@odbc_connect($dsn,$user,$pass);
if(!$this->cn){
$error="젯쌈鑒앴욋놔댄";
$this->getMess($error);
}
}
function getDo($sql){//닖깊櫓꿴璂鑒앴
$this->d=@odbc_do($this->cn,$sql);
if(!$this->d){
$error="꿴璂珂랙?鄕豈〈鵲?.....";
$this->getMess($error);
}
return $this->d;
}
function getTotal($sql){
$this->sql=$sql;
$dT=$this->getDo($this->sql);//헹悧鑒돨踏깃
$this->total=odbc_result($dT,total);//侶쟁槨부꼇콘$this->d켱?
return $this->total;
}
function getList($sql,$onepage,$page){
$this->s=$sql;
$this->onepage=$onepage;
$this->page=$page;
$this->dList=$this->getDo($this->s);//젯쌈깊돨踏깃
$this->pages=ceil($this->total/$this->onepage);
if($this->pages==0)
$this->pages++; //꼇콘혤돕뒤0女
if(!isset($this->page))
$this->page=1;
$this->fre = $this->page-1;//쉥鞫刻돨女鑒
$this->nxt = $this->page+1;
$this->nums=($this->page-1)*$this->onepage;
//if($this->nums!=0){
//}
//$this->i=0;//槨부侶꼬롸꼇콘룐陋?
return $this->dList;
}
function getFanye(){
$str="";
if($this->page!=1)
$str.="<a href=".$PHP_SELF."?page=1> 看女 </a><a href=".$PHP_SELF."?page=".$this->fre."> 품女 </a>";
else
$str.="<font color=999999>看女 품女</font>";
if($this->page<$this->pages)
$str.="<a href=".$PHP_SELF."?page=".$this->nxt."> 빈女 </a>";
else
$str.="<font color=999999> 빈女 </font>";
if($this->page!=$this->pages)
$str.="<a href=".$PHP_SELF."?page=".$this->pages."> 棺女 </a>";
else
$str.="<font color=999999> 棺女 </font>";
$str.="묾".$this->pages."女";
$str.="퀭攣啞응뒤<font color=red>".$this->page."</font>女";
return $str;
}
function getNums(){
return $this->nums;
}
function getOnepage(){//첼女茄셥係鑒
return $this->onepage;
}
function getI(){
return $this->i;
}
function getPage(){
return $this->page;
}
function getMess($error){//땍齡句口
echo"<center>$error</center>";
exit;
}
}
$pg=new Pages();
$pg->getConnect("lei","sa","star");
$pg->getList("select xs_name from xs order by xs_id",8,$page);
if($pg->getNums()!=0){
}
$i=0;
while(odbc_fetch_row($pg->dList)){
$name=odbc_result($pg->dList,"xs_name");
echo $name."<br>";
if($i==$pg->getOnepage()){//契놔琦뻔
break;
}
$i++;
}
echo$pg->getFanye();
?>