Discuz数据库查询之 - 调用主题所有相关内容 [复制链接]

moqu8 2017-9-8

12 0
  1. <?php
  2. if(!defined('IN_DISCUZ')) {
  3.         exit('Access Denied');
  4. }
  5. //首页帖子主列表
  6. $fids='0';//不调用的版块,多个用半角逗号分开

  7. if($_GET['order']=='dateline' || $_GET['order']=='views' || $_GET['order']=='replies' || $_GET['order']=='digest'){
  8.         $order= $_GET['order'];
  9. }else{
  10.         $order= 'dateline';
  11. }

  12. $messagelength='140';//内容字数

  13. $tnum=100;//每页显示的数量

  14. $begin=($_G['page']-1)*$tnum;
  15. $thread=array();
  16. require_once libfile('function/post');
  17. $rs=DB::query("
  18. SELECT t.*,p.message,p.pid,f.name,ft.attachment as forum_pic 
  19. FROM ".DB::table("forum_thread")." t 
  20. LEFT JOIN ".DB::table("forum_post")." p on p.tid=t.tid 
  21. LEFT JOIN ".DB::table("forum_forum")." f on f.fid=t.fid 
  22. LEFT JOIN ".DB::table("forum_threadimage")." ft on ft.tid=t.tid
  23. WHERE t.`fid` NOT in ($fids) and t.displayorder>=0 and p.first=1 
  24. group by t.tid 
  25. ORDER BY t.`$order` DESC
  26. LIMIT $begin , $tnum");
  27. while ($rw=DB::fetch($rs)) {
  28.         $rw['message']=messagecutstr($rw['message'],$messagelength,'');
  29.         $rw['message']=dhtmlspecialchars($rw['message']);
  30.         $Hei_portal_list[]=$rw;
  31. }
  32. $allnum=DB::result_first("select count(*) from ".DB::table("forum_thread")." where fid NOT in ($fids)");
  33. $pagenav=multi($allnum,$tnum,$_G['page'],"forum.php?order=$order");
  34. $ntpage=$_G['page']+1;
  35. $fynum=intval(floor($allnum/$tnum));
  36. ?>
$DiyPost['tid']主题TId
$DiyPost['subject']主题标题
$DiyPost[forum_pic]封面图文件名
$DiyPost['authorid']作者Uid
$DiyPost['author']作者
$DiyPost[views]查看数
$DiyPost[replies]回复数
$DiyPost[dateline]发布时间
$DiyPost['message']主题内容
$DiyPost['name']所属板块名称


最新回复 (0)
返回
支持中心
邮箱:winkill2012@qqcom
新站优化中!部分功能尚未完善,敬请谅解!
支持中心