search
Homephp教程PHP源码discuz的列表分页代码

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>


Statement
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 AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools