首页 >php教程 >PHP源码 >discuz的列表分页代码

discuz的列表分页代码

PHP中文网
PHP中文网原创
2016-05-25 17:12:251341浏览

PHP代码

discuz分页
 
 
 
funtion list(){
$page=empty($_GET['page'])?1:intval($_GET['page']);
if($page<1)
$page=1;
$perpage=40;
$perpage=mob_perpage($perpage);
$start=($page-1)*$perpage;
ckstart($start,$perpage);
$count=DB::result(DB::query("SELECT COUNT(*) FROM ".DB::table(&#39;portal_article_title&#39;)."  WHERE $wheresql"), 0);
if($count)
{
    $query = DB::query("SELECT * FROM ".DB::table(&#39;portal_article_title&#39;)." WHERE $wheresql ORDER BY dateline DESC LIMIT $start,$perpage");
    while($value = BD::fetch($query))
    {
        if($value[&#39;thumb&#39;])
        {
            $value[&#39;pic&#39;] = "data/attachment/portal/".$value[&#39;pic&#39;];
        }else{
            $value[&#39;pic&#39;] = "data/attachment/portal/".$value[&#39;pic&#39;];
        }
        $value[&#39;dateline&#39;] = date(&#39;Y-m-d&#39;, $value[&#39;dateline&#39;]);
        $value[&#39;summary&#39;] = cutstr($value[&#39;summary&#39;], 200);
        $value[&#39;subject&#39;] = getstr($value[&#39;subject&#39;], 34);//截取字符串长度,多余省略号
        $list[] = $value;
    }
    $multi=multi($count,$perpage,$page,"ask/index.php");
    if($list){
                $data[] = $list;
                $data[] = $multi;
                return $data;
    }else
    {
    return false;
    }
}
$matchname=empty($_GET[&#39;matchname&#39;]) ? &#39;&#39; : $_GET[&#39;matchname&#39;];
在调用方法时
$data=list();
$list = $data[0];
$multi = $data[1];
 
在显示页
<div class="box channel_list">
            <ul>
            <!--{if $list}-->
        <!--{loop $list $v}-->
              <li><span class="f3">·</span><a href="home.php?mod=space&uid={$v[&#39;uid&#39;]}&do=blog&id={$v[&#39;blogid&#39;]}" target="_blank">$v[&#39;subject&#39;]</a><span class="channel_date">$v[&#39;dateline&#39;]</span><span class="channel_lofts">$v[&#39;username&#39;]</span></li>
              <!--{/loop}-->
    <!--{/if}-->
               
            </ul>
            <div class="box"><!--{if $multi}--><div class="pgs cl mtm">$multi</div><!--{/if}--></div>
</div>


声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn