Analysis on how the classic PHP Forum program is written

Source: Internet
Author: User
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']};

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.