How is the classic PHP Forum program written? As a Forum programmer, I would like to write about the experiences of Forum compilation in my spare time. Taking the self-compiled open-source forum as an example, the development focus is on the first step. how to arrange the publishing blocks and write them out is quite satisfactory. The forum is divided into major sections. There are various small sections below, and there may be subsections below the small sections. In order to reduce the difficulty, how does the typical PHP Forum program be written?
As a Forum programmer, I would like to write about the experiences of Forum compilation in my spare time.
Taking the self-compiled open-source forum as an example, the development focus is on the first step. how to arrange the publishing blocks and write them out is quite satisfactory.
The forum is divided into major sections. There are various small sections below, and there may be subsections below the small sections. To reduce the difficulty, skip the section.
The design library is divided into two tables.
Two fields in the forum
Id => PRIMARY KEY
Bzone => forum name
Five fields in the forum
Id => PRIMARY KEY
Szone => small forum name
Mark => small forum description
Bid => big Forum ID, corresponding to the primary key of the big Forum
Ssort => sorting of small sections, which can affect the sorting of large sections
With the design of these two tables, can we get all the functions of forum sections? The answer is yes.
Code implementation
$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']};