3秒', PHPWEB:'PHP中文网', settings:'设置', FullScreen:'全屏', Speed:'速度', BrainwashingLoop:'洗脑循环', speedNormal:'正常', click_to_see:'点击查看完整代码可直接编辑', nextSection:'下一节', Cancel:'取消', Confirm:'确认', all_lang_string:'zh|en|zh-tw|ja|ko|ms|fr|de', Next:'下一页', Previous:'上一页', };

php分页代码实例_PHP教程

WBOY
发布: 2016-07-20 11:14:49
原创
1285 人浏览过

<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>
登录后复制

 

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...
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板