I feel that it is not as easy as I thought to be a forum, but it is not as complicated as I thought. :) after four days of bloody battles, finally, I had no idea about the Forum production. Now I have determined the data structure and organization situation of the Forum. I have referred to the ideas of sunamd, bigeagled, and Liao jiayuan, and obtained the ideas of Prince Lippi, Hoke, I would like to express my gratitude for the enthusiastic help of bigeagle prawns.
Bigeagle's article uses the stored procedures of SQL databases to achieve this, but in reality there are fewer free sites that support ASP, fewer free sites that support databases, and free sites that support SQL databases... I have never seen it before. Which one knows to tell me :), so I am waiting for the poor to only use access. I just implemented a forum similar to chinaasp in the form of ASP + access .. Let's talk less and get down to the truth.
First, let's talk about the database structure. There are two tables, one storing user information and the other storing Forum articles and information mytext. There is no need to talk about user information, mainly about the organization of articles in the mytext forum, to organize posts with the same topic, follow the parent post, post the post, and more importantly, recognize the parent post. Otherwise, a layer of reply will be arranged together, layer 2 Replies are arranged together, Layer 3... As follows:
Root sticker
Reply 1: Root post
Reply 2: Root post
Reply: Reply 1: Root post
....
Therefore, there are several key fields:
ID (automatic)
Rootid (integer): the ID of the root post (role: to achieve the same topic of the post in one)
Level (integer): number of layers to be pasted (function: indent when displayed)
Orderid (single precision): The base number of the same topic post sorting (role: the Order Basis of the same topic post sorting, that is, to prevent the case of the previous example)
Fatherid (integer): parent ID, kinship
Sort SQL statements:
Select * From mytext orderby rootid DESC, orderid, Id DESC
Display indent (the corrected "tree structure without recursion .."):
Level = 0
Response. Write "<ul>"
Do while not Rs. EOF
If RS ("level") <level then
For I = RS ("level") to level-1
Response. Write "</ul>"
Next
End if
If RS ("level")> level then
Response. Write "<ul>"
End if
Response. Write "<li> topic :.. </LI>"
Level = RS ("level ")
Rs. movenext
Loop
Response. Write "</ul>"
%>
Note: The original Article "tree structure without recursion..." is incorrect. This is the modified Code.
In addition, note that when a single precision type of data is passed, for example, orderid, the data on the request must first Replace (orderid, "", "+ "), switch csng again. Otherwise, the report "Type mismatch" will be reported. I was puzzled at the beginning, and then I will surely lose the single precision data "+" when sending the current value, it becomes a space, so we need to replace it before transformation.