discuz的列表分页代码
程序员文章站
2022-05-18 21:31:28
...
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>
上一篇: 谈谈PHP语法(4)