我们就是我们,我们不是谁的二代,我们也不要别人成为我们的二代
简单的调用论坛帖子并生成HTML
上一篇 /
下一篇 2007-01-08 22:23:56
/ 精华(1)
/ 个人分类:Discuz!5.0
查看( 3765 ) /
评论( 43 )
以下代码为鱼鱼原创,版权归鱼鱼和
一千零一夜所有.
看到有好多朋友问,就征求了臭鱼的同意把这个放出来了,注释都写的很清楚.
演示:http://cate.1001year.net/year.html 社区热点那里,就是调用的帖子.需要调用更多版块的就多加.其他修改可以参考首页调用的修改.
如果你的论坛不是生成伪静态,下面的帖子地址就改为
CODE:
http://www.***.com/viewthread.php?tid={$result[tid]}老规矩,喜欢的看,不喜欢的闪.
CODE:
<?
//论坛数据库信息
$dbuser='dbuser'; //数据库用户名
$dbpass='dbpass'; //数据库密码
$dbname='dbname'; //数据库名
$shownum='10'; //显示数量
$titlelen=35; //第一个版块的标题长度
$titlelen2=35; //第二个版块的标题长度
$titlelen3=35; //第三个版块的标题长度
$lasttime=time()-51840000; //显示两个月内的热门贴
mysql_connect('',$dbuser,$dbpass);
mysql_query("SET NAMES GBK");
mysql_select_db($dbname);
//-------------------美女写真-------------------
$select = mysql_query("SELECT tid,fid,author,lastpost,dateline,lastposter,views,subject,replies FROM cdb_threads where fid=27 and lastpost>$lasttime and closed=0 ORDER BY replies DESC LIMIT 0, $shownum");
$result=mysql_fetch_array($select);
$show.= "<table width='100%' border='0' cellspacing='0' cellpadding='0'>\r\n";
while ($result)
{
$longname=$result['subject'];
//截取帖子标题长度
if(strlen($result['subject']) > $titlelen)
{
$result['subject']=substr($result['subject'],"0",$titlelen-4).chr(0);
$result['subject']=$result['subject']."...";
}
$lastpost=date('Y-m-d',$result[lastpost]);
$dateline=date('Y-m-d',$result[dateline]);
$show.="<tr><td>";
$show.="<a href=http://bbs.1001year.net/thread-{$result[tid]}-1-1.html target=_blank title='标题:{$longname}
作者:{$result['author']}
发表日期:{$dateline}
最后回复:{$lastpost}({$result['lastposter']})
阅读次数:{$result['views']}
回复次数:{$result['replies']}'>".$result['subject']."</a>";
$show.="</td></tr>";
$result=mysql_fetch_array($select);
}
$show.="</table>";
$filename='bbs_mv.html';
$handle=fopen ($filename,"w");
fwrite($handle,$show);
fclose($handle);
unset ($show);
//-------------------精彩贴图-------------------
$select = mysql_query("SELECT tid,fid,author,lastpost,dateline,lastposter,views,subject,replies FROM cdb_threads where fid=20 and lastpost>$lasttime and closed=0 ORDER BY replies DESC LIMIT 0, $shownum");
$result=mysql_fetch_array($select);
$show.= "<table width='100%' border='0' cellspacing='0' cellpadding='0'>\r\n";
while ($result)
{
$longname=$result['subject'];
//截取帖子标题长度
if(strlen($result['subject']) > $titlelen2)
{
$result['subject']=substr($result['subject'],"0",$titlelen2-4).chr(0);
$result['subject']=$result['subject']."...";
}
$lastpost=date('Y-m-d',$result[lastpost]);
$dateline=date('Y-m-d',$result[dateline]);
$show.="<tr><td>";
$show.="<a href=http://bbs.1001year.net/thread-{$result[tid]}-1-1.html target=_blank title='标题:{$longname}
作者:{$result['author']}
发表日期:{$dateline}
最后回复:{$lastpost}({$result['lastposter']})
阅读次数:{$result['views']}
回复次数:{$result['replies']}'>".$result['subject']."</a>";
$show.="</td></tr>";
$result=mysql_fetch_array($select);
}
$show.="</table>";
$filename='bbs_tt.html';
$handle=fopen ($filename,"w");
fwrite($handle,$show);
fclose($handle);
unset ($show);
//-------------------占星奇缘-------------------
$select = mysql_query("SELECT tid,fid,author,lastpost,dateline,lastposter,views,subject,replies FROM cdb_threads where fid=78 and lastpost>$lasttime and closed=0 ORDER BY replies DESC LIMIT 0, $shownum");
$result=mysql_fetch_array($select);
$show.= "<table width='100%' border='0' cellspacing='0' cellpadding='0'>\r\n";
while ($result)
{
$longname=$result['subject'];
//截取帖子标题长度
if(strlen($result['subject']) > $titlelen2)
{
$result['subject']=substr($result['subject'],"0",$titlelen3-4).chr(0);
$result['subject']=$result['subject']."...";
}
$lastpost=date('Y-m-d',$result[lastpost]);
$dateline=date('Y-m-d',$result[dateline]);
$show.="<tr><td>";
$show.="<a href=http://bbs.1001year.net/thread-{$result[tid]}-1-1.html target=_blank title='标题:{$longname}
作者:{$result['author']}
发表日期:{$dateline}
最后回复:{$lastpost}({$result['lastposter']})
阅读次数:{$result['views']}
回复次数:{$result['replies']}'>".$result['subject']."</a>";
$show.="</td></tr>";
$result=mysql_fetch_array($select);
}
$show.="</table>";
$filename='bbs.html';
$handle=fopen ($filename,"w");
fwrite($handle,$show);
fclose($handle);
unset ($show);
?>
论坛模式
推荐
收藏
分享给好友
管理
TAG:
简单
调用论坛帖子
生成HTML