本帖最后由 王杰1212 于 2014-9-17 09:10 编辑
如下代码,
这是一个调运所在版块精华的帖子的代码
请问我怎么修改能改成调运本版块 热门 帖子呢
- function get_pic($n,$atturl,$bk_id,$jinghua){
- date_default_timezone_set('Asia/Shanghai');
- $datas=array();
- $pic=array();
- $n=(int)$n;
- $sql="SELECT t.tid,timage.attachment,p.message,p.subject FROM ".DB::table('forum_threadimage').
- " as timage join ".DB::table('forum_thread')." as t on timage.tid=t.tid
- join ".DB::table('forum_post')." as p on t.tid=p.tid where $jinghua t.fid=$bk_id order by tid desc ";
- //debug($sql);
- $querys=DB::query($sql);
- while($mood = DB::fetch($querys)) {
- if($mood['subject']){
- $mood['attachment']=$atturl."forum/".$mood['attachment'];
- if(!(fopen($mood['attachment'],"r")))continue;
- $pic[]=$mood;
-
- }
- }
- foreach($pic as $k=>$v){
- if($k<4){
- $sql="SELECT subject,message,dateline FROM ".DB::table('forum_post')." where tid=".$v['tid']." order by subject desc";
- $query=DB::query($sql);
- $mood = DB::fetch($query);
- if($mood['subject']){
- $mood['message']=preg_replace("/(\[attach\].*\[\/attach\])/"," ",$mood['message']);
- $datas[$k]['attachment']=$v['attachment'];
- $datas[$k]['subject']=$mood['subject'];
- $datas[$k]['message']=dhtmlspecialchars($mood['message']);
- $datas[$k]['time']=date('Y-m-d',$mood['dateline']);
- $datas[$k]['url']="forum.php?mod=viewthread&tid=".$pic[$k]['tid'];
- }
- }
- }
- return $datas;
-
- }
复制代码 补充:这个代码同时还调运了帖子内的图片。
|