Home >Backend Development >PHP Tutorial >Learn PHP paging code examples_PHP tutorial

Learn PHP paging code examples_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:25:56863browse

There are many ways to paginate in PHP. Today we will use a small example to demonstrate this function.

Copy code The code is as follows:

$result = "
";

// Previous page
if ($offset>0) {
$result .= "

  • ;a href="".$url.'offset='.($offset-$maxrow)."">Prev
                                                                                    🎜> $pages = $allPageNums; //Total number of pages
    $page = $curPage; //Current page number
    $page_len = 9;
    $page_len = ($page_len%2)?$page_len :$pagelen+1;//Number of page numbers
    $pageoffset = ($page_len-1)/2;//Offset to the left and right of page number
    if($pages>$page_len){
    //If the current page is less than or equal to the left offset
                                                                                                                                                                                   The page is greater than the left offset
    //If the right offset of the current page number exceeds the maximum number of pages
    if($page+$pageoffset>=$pages+1){
    $init = $pages-$page_len+ 1;
        $max_p = $pages;           $max_p = $page+ $pageoffset;
    } }
    } }
    } else {

    for($i=$init; $i
    if ( $i == $curPage ) {
    $result .= "
  • $i
  • ";
    continue;
    }

    $result .= "
  • $i
  • ";

    }

    // Print next page
    if ( $allnums > ($offset+$maxrow) ) {                                                                                                                                                                            🎜>                                                                                                             




    http://www.bkjia.com/PHPjc/824876.html

    www.bkjia.com

    true

    http: //www.bkjia.com/PHPjc/824876.html

    TechArticle

    There are many ways to paginate in PHP. Today we will use a small example to demonstrate this function. Copy the code The code is as follows: $result = "div class="page-num"ul class="fn-clear""; // Previous page...



    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn