复制内容代码://调用休闲娱乐新贴//
$query = $db-query(SELECT t.*, f.name FROM {$tablepre}threads t, {$tablepre}forums f WHE ...
复制内容
代码:
//调用休闲娱乐新贴//
$hack_cut_str =22; //修改标题显示字数
$hack_cut_strauthor = 9;
$fid19_new_post_threadlist = array();
$nthread = array();
$query = $db->query("SELECT t.*, f.name FROM {$tablepre}threads t, {$tablepre}forums f WHERE t.fid<>'$fid' [color=Red]AND f.fid=t.fid AND f.fid in (19,21,22,23,25,26)[/color] AND t.displayorder not in (-1,-2) ORDER BY t.dateline DESC LIMIT 0, [color=Blue]10");[/color]
while($nthread = $db->fetch_array($query)) {
$nthread['forumname'] = $nthread['name'];
$nthread['view_subject'] = cutstr($nthread['subject'],$hack_cut_str);
$nthread['view_author'] = cutstr($nthread['author'],$hack_cut_strauthor);
$nthread['date']= gmdate("$dateformat $timeformat", $nthread['dateline'] + $timeoffset * 3600);
$nthread['lastreplytime']= gmdate("$dateformat $timeformat", $nthread[lastpost] + ($timeoffset * 3600));
if($nthread['highlight']) {
$string = sprintf('%02d', $nthread['highlight']);
$stylestr = sprintf('%03b', $string[0]);
$nthread['highlight'] = 'style="';
$nthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
$nthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
$nthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
$nthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
$nthread['highlight'] .= '"';
} else {
$nthread['highlight'] = '';
}
$fid19_new_post_threadlist[] = $nthread;
}这是在一个
home文件目录找到的bbs.
php的代码,当中有很多相同于上述的代码产生,这就是产生了
查询多次,不同资料的作用.而如果没有学过PHP时,你会发现有一句很难理:("SELECT t.*, f.name FROM {$tablepre}threads t, {$tablepre}forums f WHERE t.fid<>'$fid' AND f.fid=t.fid AND f.fid in (19,21,22,23,25,26) AND t.displayorder not in (-1,-2) ORDER BY t.dateline DESC LIMIT 0, 10");
这是一句常用的
SQL查询命令.详细就不说了, 注意其中几点就行.
红色部分,fid in (19,21,22,23,25,26) 这儿代表版块的FID号, 你想要调用哪个版面就写哪个号.
蓝色部分 10"); 这儿是SQL的数值
参数,是信息条数的意思.
当然,还有其它的
精华, 还有推荐等等,都还有参数加上才可以查询得出来. 包括附件等等.
现在了解这些,也许对你有所帮助吧. 大家齐动手吧.