PHP paging code example_PHP tutorial

WBOY
Release: 2016-07-20 11:14:49
Original
1286 people have browsed it

<span $result</span> = "<div class=\"page-num\"><ul class=\"fn-clear\">"<span ;
    
    </span><span //</span><span  上一页</span>
    <span if</span> (<span $offset</span>>0<span ) {
        </span><span $result</span> .= "<span <li>
            <a href=\"</span>".<span $url</span>.'offset='.(<span $offset</span>-<span $maxrow</span>)."<span \">Prev</a>
        </li></span>"<span ;
    }
    
    </span><span $pages</span> = <span $allPageNums</span>;  <span //</span><span 总页数</span>
    <span $page</span> = <span $curPage</span>;    <span //</span><span 当前页数</span>
    <span $page_len</span> = 9<span ;
    </span><span $page_len</span> = (<span $page_len</span>%2)?<span $page_len</span>:<span $pagelen</span>+1;<span //</span><span 页码个数 </span>
    <span $pageoffset</span> = (<span $page_len</span>-1)/2;<span //</span><span 页码个数左右偏移量 </span>
    <span if</span>(<span $pages</span>><span $page_len</span><span ){ 
        </span><span //</span><span 如果当前页小于等于左偏移 </span>
        <span if</span>(<span $page</span><=<span $pageoffset</span><span ){ 
            </span><span $init</span>=1<span ; 
            </span><span $max_p</span> = <span $page_len</span><span ; 
        }</span><span else</span>{<span //</span><span 如果当前页大于左偏移 
            //如果当前页码右偏移超出最大分页数 </span>
            <span if</span>(<span $page</span>+<span $pageoffset</span>>=<span $pages</span>+1<span ){ 
                </span><span $init</span> = <span $pages</span>-<span $page_len</span>+1<span ;<br />         $max_p = $pages; 
            }</span><span else</span><span { 
                </span><span //</span><span 左右偏移都存在时的计算 </span>
                <span $init</span> = <span $page</span>-<span $pageoffset</span><span ; 
                </span><span $max_p</span> = <span $page</span>+<span $pageoffset</span><span ; 
            } 
        } 
    } else {<br />  <br />      $init = 1;<br />      $max_p = $pages;<br />  }

    </span><span for</span>(<span $i</span>=<span $init</span>; <span $i</span><=<span $max_p</span>; <span $i</span>++<span ) {
        
        </span><span if</span> ( <span $i</span> == <span $curPage</span><span  ) {
            </span><span $result</span> .=    "<li class=\"on\"><a href=\"".<span $url</span>.'offset='.(<span $i</span>*<span $maxrow</span>)."\" ><span $i</span></a></li>"<span ;
            </span><span continue</span><span ;
        }
        
        </span><span $result</span> .=    "<li><a href=\"".<span $url</span>.'offset='.((<span $i</span>-1)*<span $maxrow</span>)."\"><span $i</span></a></li>"<span ;
        
    }
    
    </span><span //</span><span  打印下一页</span>
    <span if</span> ( <span $allnums</span> > (<span $offset</span>+<span $maxrow</span><span ) ) {
        </span><span $result</span> .=    "<span <li>
            <a href=\"</span>".<span $url</span>.'offset='.(<span $offset</span>+<span $maxrow</span>)."<span \">Next</a>
        </li></span>"<span ;
    }</span>
Copy after login

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/440264.htmlTechArticle= "div class="page-num"ul class="fn-clear"" ( 0 .= " ". .'offset='.( - )." " = ; = ; = 9 = ( %2)? : +1; = ( -1)/2; ( ( = =1 = { ( + = +1 = - +1 $max_p = $pages; } = - = + $init...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template