Ask for a specific Php+mysql page-no online search

Source: Internet
Author: User
Ask for a specific Php+mysql page-----don't search online.
One, from page a click on page b for pagination display
Second, pagination display of the code
Third, there First prev 1 2 3 4 5 Next lastThe function
Four, after the page can Normal DisplayThe content is to click on the next page to display the database data (the parameters of page A is not lost),


------Solution--------------------
Class page{
Private $_page_num;//Total Pages
Private $_page_size=10;//number of articles per page
Private $_page_url;//url Links
Private $_limit;//limit1
Private $_page_total;//Total Pages
Private $_page;//page value of paging
Private $_list_size=10;//This shows the number of bars for the second paging method
Private $_page_sort=3;//page on both sides of the distance
Public function __construct ($_total,$_pagesize,$_list_size) {
$this->_page_size=$_pagesize;
$this->_page_total=$_total;
$this->_list_size = $_list_size;
$this->_page_num = round ($this->_page_total/$this->_page_size);
$this->_page= $this->getnum ();
$this->_limit= "Limit". $this->_page* $this->_page_size. ",". $this->_page_total=$_total;
$this->_page_url= $this->seturl ();
}
/**
* Get the current page
* Enter description here ...
*/
Private Function Getnum () {
if (Isset ($_get[' page ')) {
if (Is_numeric ($_get[' page ')) {
if ($_get[' page ']>0) {
if (ceil ($_get[' page ') >=1 && ceil ($_get[' page ') <= $this->_page_num) {
return ceil ($_get[' page ');
}elseif (ceil ($_get[' page ') > $this->_page_num) {
return $this->_page_num;
}
}else{
return 1;
}
}else{
return 1;
}
}else{
return 1;
}
}
/**
* Convert Links
* Enter description here ...
*/
Private Function SetUrl () {
$_url=$_server[' Request_uri '];//GET request address
$_par=parse_url ($_url);//Parse URL
if (isset ($_par[' query ')) {//To determine if AA=BB is present in this format
$_URL=PARSE_STR ($_par[' query '],$_query);//Refactor URL
unset ($_query[' page ');
$_url=$_par[' path ']. '? '. Http_build_query ($_query);
}else{
$_url=$_url. '? ';
}
return $_url;
}

Public function limit () {
return $this->_limit;
}

Public Function Pagenum () {
return $this->_page_num;
}

/*
Public Function page () {
return $this->_page;
}
Public Function Pageurl () {
return $this->_page_url;
}
*/

Private Function First () {
Return "_page_url." &page=1> Home ";
}
Private Function End () {
Return "_page_url." &page= ". $this->_page_num." > Last ";
}
Private Function prev () {
if ($this->_page>1) {
Return "_page_url." &page= ". ($this->_page-1). " > Previous page ";
}else{
Return ' previous page ';
}
}
Public function next () {
if ($this->_page< $this->_page_num) {
Return "_page_url." &page= ". ($this->_page+1). " > next Page ";
}else{
Return ' next page ';
}
}
Private Function pagelist_1 () {
$_page= ";
for ($i =1; $i <= $this->_page_num; $i +) {
$_page.= "_page_url." &page= ". $i." > ". $i.";
}
return $_page;
}
Private Function pagelist_2 () {
$_page= ";
  • 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.