当前位置:Gxlcms > PHP教程 > 浅析经典的PHP论坛程序是怎么写成的

浅析经典的PHP论坛程序是怎么写成的

时间:2021-07-01 10:21:17 帮助过:7人阅读

浅析经典的PHP论坛程序是如何写成的?
作为一个论坛程序爱好者,趁空闲时间写一下编写论坛的心得。
以自己编写的开源论坛为例,开发重点是在第一步,如何排列出版块,写出这个,接下去就比较顺手了。
版块分为大版块,下面有各个小版块,小版块下面可能还有子版块。为了减少难度,子版块部分忽略不谈。
设计库设计分为2张表
大版块2个字段
id => 主键
bzone =>大版块名称


小版块5个字段
id => 主键
szone => 小版块名称
mark => 小版块说明文字
bid => 大版块ID,对应大版块的主键
ssort => 小版块排序,可以以小版块影响大版块的排序

以这2张表的设计就能够全部搞定论坛版块的功能部分?答案是肯定的

代码实现
$sql_block   = "select * from " . C('db_prefix') . "small_block order by ssort desc,bid desc,szone desc";
$query_block = mysql_query($sql_block);
$data_block = array();
$data_big = array();
$time1 = date("Y-m-d");
$time1 .= " 00:00:00";
$time2 = date("Y-m-d");
$time2 .= " 23:59:59";
while ($arr_block = mysql_fetch_array($query_block)) {
$data_block[] = $arr_block;

$bsql = "select * from " . C('db_prefix') . "big_block where id=" . $arr_block['bid'];
$barr = mysql_fetch_array(mysql_query($bsql));
$data_big[$arr_block['bid']] = $barr['bzone'];

${'zhuti' . $arr_block['id']} = mysql_num_rows(mysql_query("select * from " . C('db_prefix') . "talk where parentid=" . $arr_block['id']));
$this->assign("zhuti" . $arr_block['id'], ${'zhuti' . $arr_block['id']});

${'tiezi1' . $arr_block['id']} = mysql_num_rows(mysql_query("select * from " . C('db_prefix') . "talk where parentid=" . $arr_block['id']));
${'tiezi2' . $arr_block['id']} = mysql_num_rows(mysql_query("select * from " . C('db_prefix') . "reply where parentid2=" . $arr_block['id']));
${'tiezi' . $arr_block['id']} = ${'tiezi1' . $arr_block['id']} + ${'tiezi2' . $arr_block['id']};

人气教程排行