PHP development small forum tutorial forum section
Let’s start with the first step of building a forum
The first step is to start from the homepage: read the information in the database. The main pageis to cycle through all forum sections in the 'forums' table. For those with basic knowledge, the query statement is very easy:
When running like this, the page does not have any output, because the database we just created No data! So, I hope to make the forum more user-friendly. What if there is no forum section and the words "Sorry, the forum is still under construction..." should be output? ? We can use mysql_num_rows() to get the number of results. The code is as follows
Now let’s use css style and layout to make our page look more beautiful. The code is as follows
论坛
论坛列表[添加 ] | ||
主题 | 论坛 | 最后更新 |
" . $row["forum_name"] . "" . $row["forum_description"] ?> | 对不起,论坛正在建设中,感谢你的关注...... | "; } ?>
There is no data in the database yet, so when we run the homepage, it only displays "Sorry, the forum is still under construction...". Since we really want to see the results, let's add a few pieces of data to the database next!