Due to work reasons, a table stored recorded table is involved, requiring all of the tree tables in the program, and outputs the corresponding data content. Since there are many places involved in this operation, many "forums" on the network are typical use of tree storage records, and throw out with you. In many data, there are programs that introduce the tree records, but many of them use recursive methods. We know that recursive method logic is relatively simple, and it is easier to actually operate. But it is a maximum disadvantage that it is too much resources, and the speed is too slow. If this method is used on the "Forum" of the Internet, it will be a very serious problem in the case of the table record. The following program solves a big problem in the work of the author and will be applied to the forum of the YUKING.126.com. I have used a very fast stack to implement this operation, but it is relatively difficult to operate. We take the process as an example to explain this process, first understand the table structure: 1. Table structure (Article) Self int record ID number Father int parent record ID number Title char Post title Author char Postage DateTime Date Posting Date Time Hits Int Click on the number of reply int replys ..... Depending on the specific situation, we can also have more fields 1) Key Description: Self is the ID number of the record, this should be an automatic growth Fields, not allowed to repeat. Father is a field that records the parent node ID number of this node. If the record content is "post-post" this field value should be the ID number of the "master post". If the record is "primary post", its formation should be "0" 2) The following two records are parent and child records: Self Father Title Author ..... 1 0 Who can help me three-foot cat 2 1 Can you help you? Online flying two, the operation method first, we read the records of all the parent sides "0" is "primary post", which is put into the stack. Then output a record ("master post") data located on the top of the stack, and clear the top of the stack, the top of the stack is moved. Then look for the record of all the parent sides for the stack ("Post Post"), which is also put on the top of the stack. Note that there is no, in these two steps, we have completed the work of putting a parent record and expand its sub-node. The rest of the work is only pushed in turn until the stack is empty. Of course, there may be some requirements, such as the number of layers, reply, etc., we can implement it with a slight improvement. Third, here is the original code after organizing <% SET RS = Server.createObject ("AdoDb.Recordset") SQL_Text = "SELECT * from ARTICLE WHERE Father = 0 ORDER BY dateTime Desc" rsopen sql_text, bbs_connectionstring looks for all fat The point is 0 nodes, that is, "master post". DIM Stack (100, 8) defines the stack, I am 100 (8 means that each stack element stores 8 field values). The stack size can be defined according to the actual situation, and the "maximum layer * maximum number of expansion" can be calculated according to this formula.