自己写的非常简单好用的PHP的MYSQL分页类
dbadd=$dbadd; $this->dbuser=$dbuser; $this->dbpwd=$dbpwd; $this->dbname=$dbname; $this->tablename=$tablename; $this->num=$num; $this->total=$this->gettotal(); //得到总条数 $this->totalpage=ceil($this->total/$this->num); //获取总页数 $this->page=$this->getpage(); //得到当前页数 $this->limit=$this->setlimit(); //得到查询的数据 $this->arrs=$this->getarrs(); //得到查询的结果 $this->col=$this->getcol(); //获取总列数 $this->nostart=($this->page-1)*$num+1; $this->noend=$this->page==$this->totalpage ? $this->total : $this->page*$num; $this->head=$this->page==1 ? "首页" : "首页"; $this->end=$this->page==$this->totalpage ? "尾页" : "totalpage}" _href=".html?page={$this->totalpage}">尾页"; $this->last=$this->page==1 ? "上一页" : "page-1)."" _href=".html?page=".($this->page-1)."">上一页"; $this->nexts=$this->page==$this->totalpage ? "下一页" : "page+1)."" _href=".html?page=".($this->page+1)."">下一页"; } private function getcol(){ $linkss=mysql_connect($this->dbadd, $this->dbuser, $this->dbpwd); mysql_select_db($this->dbname, $linkss); $result=mysql_query("select * from {$this->tablename}", $linkss); $col=mysql_num_fields($result); mysql_close($linkss); return $col; } private function getarrs(){ //根据条件再次查询并返回结果 $sql="select * from {$this->tablename} limit {$this->limit}, {$this->num}"; $links=mysql_connect($this->dbadd, $this->dbuser, $this->dbpwd); mysql_select_db($this->dbname, $links); $result=mysql_query($sql, $links); while($arr=mysql_fetch_assoc($result)){ $arrs[]=$arr; } return $arrs; mysql_close($links); } private function setlimit(){ return ($this->page-1)*$this->num; } private function getpage(){ $page=isset($_GET["page"]) ? $_GET["page"] : 1; $page=$page>$this->totalpage ? $this->totalpage : $page; $page=$pagedbadd, $this->dbuser, $this->dbpwd); mysql_select_db($this->dbname, $link); $result=mysql_query("select * from {$this->tablename}", $link); $total=mysql_num_rows($result); mysql_close($link); return $total; } function __get($args){ switch($args){ case "arrs": //根据条件查询出的结果,是二维数组 return $this->arrs; break; case "totalpage": //总页数 return $this->totalpage; break; case "col": //总列数 return $this->col; break; case "page": //当前页 return $this->page; break; case "nostart": //当前页显示的记录的起始条数 return $this->nostart; break; case "noend": //当前页显示的记录的结束条数 return $this->noend; break; case "head": //首页按钮 return $this->head; break; case "end": //尾页按钮 return $this->end; break; case "last": //上一页按钮 return $this->last; break; case "nexts": //下一页按钮 return $this->nexts; break; } } } ?>
로그인 후 복사
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사
R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
2 몇 주 전
By 尊渡假赌尊渡假赌尊渡假赌
스플릿 소설을이기는 데 얼마나 걸립니까?
1 몇 달 전
By DDD
R.E.P.O. 최고의 그래픽 설정
2 몇 주 전
By 尊渡假赌尊渡假赌尊渡假赌
어 ass 신 크리드 그림자 : 조개 수수께끼 솔루션
1 몇 주 전
By DDD
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
2 몇 주 전
By 尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제
Gmail 이메일의 로그인 입구는 어디에 있나요?
7407
15


자바 튜토리얼
1630
14


Cakephp 튜토리얼
1358
52


라라벨 튜토리얼
1268
25


PHP 튜토리얼
1218
29

