tailieunhanh - PHP and MySQL Web Development - P145

PHP and MySQL Web Development - P145: PHP and MySQL Web Development teaches the reader to develop dynamic, secure, commercial Web sites. Using the same accessible, popular teaching style of the first edition, this best-selling book has been updated to reflect the rapidly changing landscape of MySQL and PHP. | 692 Chapter 29 Building Web Forums row children expand depth 1 expanded sublist This last line will create the new treenodes following exactly the same process we have just walked through but for the next level down the tree. This is the recursive part. A parent tree node is calling the treenode constructor passing its own postid as parent and adding one to its own depth before passing it. Each treenode in turn will be created and create its own children until we run out of replies or levels that we want to expand to. After all that s done we call the root treenode s display function this is back in dis-play_tree as follows tree- display row sublist The display function begins by checking whether this is the dummy root node if this- m_depth -1 In this way the dummy can be left out of the display. We don t want to completely skip the root node though. We do not want it to appear but it needs to notify its children that they need to display themselves. The function then starts drawing the table containing the articles. It uses the modulus operator to decide what color background this row should have hence they alternate color alternate rows echo tr td bgcolor if row 2 echo cccccc else echo ffffff It then uses the m_depth member variable to work out how much to indent the current will see by looking back at the figures that the deeper level a reply is on the further it is indented. This is done as follows indent replies to the depth of nesting for i 0 i this- m_depth i echo img src images height 22 width 22 alt valign bottom The next part of the function works out whether to supply a plus or minus button or nothing at all display or - or a spacer if sublist this- m_children sizeof this- m_childlist Viewing the Tree of Articles 693 we re on the main page have some children and they re expanded we are expanded - offer button to collapse echo a href collapse . this- m_postid. . this- m_postid. img src images valign bottom height 22

TỪ KHÓA LIÊN QUAN