Home > php教程 > PHP源码 > body text

discuz的列表分页代码

PHP中文网
Release: 2016-05-25 17:12:25
Original
1298 people have browsed it

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>
Copy after login


Related labels:
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!