PHP implements the paging class of the database

Source: Internet
Author: User
PHP implements the paging class of the database

Recently in the implementation of a product management project, the product data can be paged output.
Therefore, the implementation of a paging class operation, the code is as follows:

Class seppage{var$rs;var$pagesize;var$nowpage;var$array;var$conn;var$sqlarr; function ShowData ($sqlarr,$conn,$pagesize,$nowpage){//Definition methodif(!Isset$nowpage)||$nowpage=="")//Determine if the variable value is empty$this -Nowpage=1;Else$this -Nowpage=$nowpage;$this -PageSize=$pagesize;//define the number of records per page output$this -Conn=$conn;//The identity returned by the linked database$this -Sqlstr=$strsql;//Execute Query statement$this -Rs=$this -Conn -Pageexecute ($this -SQLSTR,$this -PageSize$this -Nowpage); @this -Array=$this -Rs -GetRows ();//Get Record Countif(Count ($this -Array)==0||$this -Rs==false)returnfalse;Elsereturn$this -Array; } function ShowPage ($contentname,$utits,$anothersearchstr,$anothersearchstrs,$class){$allrs=$this -Conn -Execute ($this -SQLSTR);//Execute Query statement$record=Count$allrs -GetRows ());//Total Statistics Records$pagecount=Ceil ($record/$this -pagesize);//Calculate a total of several pages$str.=$contentname." ".$record."& nbsp;".$utits." "Per page&nbsp". $this->pagesize."&nbsp". $utits."&nbsp The&nbsp". $this->rs->absolutepage ()."&nbsp; page/Shared&nbsp". $pagecount."&nbsp; page"; $str. = "&nbsp&nbsp&nbsp&nbsp"; if (! $this->rs->atfirstpage ()) $str. = "<a href=". $_server[' Php_self ')."?Page=1&Parameter1=". $anothersearchstr."&Parameter2=". Anothersearchsstrs."Class=". $class.">Home</A>"; else $str. = "<Font Color=' #555555 '>Home</font>"; $str. = "&nbsp"; if (! $this->rs->atlastpage ()) $str. = "<a href=". $_server[' Php_self ')."?Page=($this -Rs -AbsolutePage ()+1)."& parameter1=".$anothersearchstr."& parameter2=".Anothersearchsstrs."class=".$class."> Next page";Else$str.="Next Page";$str.=" ";if(!$this -Rs -Atlastpage ())$str.=". $_server [' php_self '] ."? Page= ". $pagecount." & Parameter1= ". $anothersearchstr." & Parameter2= ". Anothersearchsstrs." Class= ". $class."        > Last ";        else $str. = "Last";        if (count ($this->array) ==0 | | $this->rs==false) return "";    else return $str; }}

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the PHP implementation of the database paging class, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    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

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.