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

discuz的列表分页代码

May 25, 2016 pm 05:12 PM

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('portal_article_title')."  WHERE $wheresql"), 0);
if($count)
{
    $query = DB::query("SELECT * FROM ".DB::table('portal_article_title')." WHERE $wheresql ORDER BY dateline DESC LIMIT $start,$perpage");
    while($value = BD::fetch($query))
    {
        if($value['thumb'])
        {
            $value['pic'] = "data/attachment/portal/".$value['pic'];
        }else{
            $value['pic'] = "data/attachment/portal/".$value['pic'];
        }
        $value['dateline'] = date('Y-m-d', $value['dateline']);
        $value['summary'] = cutstr($value['summary'], 200);
        $value['subject'] = getstr($value['subject'], 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['matchname']) ? '' : $_GET['matchname'];
在调用方法时
$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['uid']}&do=blog&id={$v['blogid']}" target="_blank">$v['subject']</a><span class="channel_date">$v['dateline']</span><span class="channel_lofts">$v['username']</span></li>
              <!--{/loop}-->
    <!--{/if}-->
               
            </ul>
            <div class="box"><!--{if $multi}--><div class="pgs cl mtm">$multi</div><!--{/if}--></div>
</div>
Copy after login


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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)