请问大大下,如果我不要那些被删除的帖子出现在首页4格要如何加入那个代码?以下是我的index.php。 :)
- //---------------首页四格 -- 2/2
- $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
- //今日发贴排行
- $tomonth=date(n);
- $todate=date(j);
- $toyear=date(Y);
- $time=mktime(0,0,0,$tomonth,$todate,$toyear);
- $query=$db->query("select count(pid) as num,authorid,author from $tablepre"."posts where dateline>=$time group by authorid order by num desc limit 0,8");
- while($result=$db->fetch_array($query)){
- $poststar.="<a href=viewpro.php?uid=".$result[authorid].">".$result[author]."</a> (<font color=red>".$result[num]."</font>)<br>";
- }
- //今日发贴排行
- $hack_subject_len=30; //每个标题最多显示得字数
- $hack_subject_num=8; //需要显示记录数
- $hack_newthreads_threadlist = array();
- $thread = array();
- //最新贴
- $query = $db->query("SELECT dateline,typeid,tid,subject,author,views,replies,lastpost,lastposter FROM {$tablepre}threads WHERE fid NOT IN(9,12,23,27,28,32,36) ORDER BY dateline DESC LIMIT 0, $hack_subject_num");
- while($thread = $db->fetch_array($query)) {
- $typeselect = typeselect($typeid);
- $thread['forumname'] = $thread['name'];
- $thread['date']= gmdate("$dateformat $timeformat", $thread['dateline'] + $timeoffset * 3600);
- $thread['lastreplytime']= gmdate("$dateformat $timeformat", $thread[lastpost] + ($timeoffset * 3600));
- $thread[subject0]=$thread[subject];
- $thread['subject'] = cutstr($thread['subject'], $hack_subject_len);
- $hack_newthreads_threadlist[] = $thread;
- }
- //最新贴
- //最新回复
- $query = $db->query("SELECT dateline,tid,subject,author,views,replies,lastpost,lastposter FROM {$tablepre}threads WHERE fid NOT IN(9,12,23,27,28,32,36) AND replies > 0 ORDER BY lastpost DESC LIMIT 0, $hack_subject_num");
- while($thread = $db->fetch_array($query)) {
- $thread[subject0]=$thread[subject];
- $thread['forumname'] = $thread['name'];
- $thread['date']= gmdate("$dateformat $timeformat", $thread['dateline'] + $timeoffset * 3600);
- $thread['lastreplytime']= gmdate("$dateformat $timeformat", $thread[lastpost] + ($timeoffset * 3600));
- $thread[subject] = cutstr($thread[subject], $hack_subject_len);
- $threadreply[] = $thread;
- }
- //最新回复
- //热帖
- $hack_cut_str = 30; //修改标题显示字数
- $hack_cut_strauthor = 8;
- //这个可以选择安装或者不安装//
- //热贴指定天数//
- $this_time= time();
- $sort_time = $today - ( 60*60*24*30); //30天内,或者改成7天也就是一周
- $new_hot_threadlist = array();
- $mthread = array();
- $query = $db->query("SELECT t.*, f.name FROM {$tablepre}threads t, {$tablepre}forums f WHERE t.fid<>'$fid' AND f.fid=t.fid AND f.fid NOT IN(9,23,27,28,32,36) AND t.closed NOT LIKE 'moved|%' AND t.replies !=0 and t.dateline > $sort_time ORDER BY t.views DESC LIMIT 0, 10"); //修改显示帖子条数
- while($mthread = $db->fetch_array($query)) {
- $mthread['forumname'] = $mthread['name'];
- $mthread['view_subject'] = cutstr($mthread['subject'],$hack_cut_str);
- $mthread['view_lastposter'] = cutstr($mthread['lastposter'],$hack_cut_strauthor);
- $mthread['date']= gmdate("$dateformat $timeformat", $mthread['dateline'] + $timeoffset * 3600);
- $mthread['lastreplytime']= gmdate("$dateformat $timeformat", $mthread[lastpost] + ($timeoffset * 3600));
- if($mthread['highlight']) {
- $string = sprintf('%02d', $mthread['highlight']);
- $stylestr = sprintf('%03b', $string[0]);
- $mthread['highlight'] = 'style="';
- $mthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
- $mthread['highlight'] .= '"';
- } else {
- $mthread['highlight'] = '';
- }
- $new_hot_threadlist[] = $mthread;
- }
- //热帖,四格代码结束//
- //---------------首页四格 -- 2/2 end
复制代码
我试了一楼的方法但出现错误。这个是错误讯息...我是用Discuz6,本地主机测试的。
Discuz! info: MySQL Query Error
User: J34
Time: 2007-8-2 2:08pm
Script: /forum/index.php
SQL: SELECT dateline,typeid,tid,subject,author,views,replies,lastpost,lastposter FROM [Table]threads WHERE t.displayorder>=0 AND fid NOT IN(9,12,23,27,28,32,36) ORDER BY dateline DESC LIMIT 0, 8
Error: Unknown column 't.displayorder' in 'where clause'
程序文件跟数据库有冲突,请使用正确的程序文件上传上去覆盖
Similar error report has beed dispatched to administrator before.
[ 本帖最后由 jourdan 于 2007-8-2 14:20 编辑 ] |