Heim  >  Artikel  >  Backend-Entwicklung  >  php中论坛帖子展开,书本知识看不懂啊靠~请帮帮小弟我

php中论坛帖子展开,书本知识看不懂啊靠~请帮帮小弟我

WBOY
WBOYOriginal
2016-06-13 11:59:411015Durchsuche

php中论坛帖子展开,书本知识看不懂啊靠~,请帮帮我,

<?php <br />// functions for loading, contructing and <br>// displaying the tree are in this file <br><br>class treenode<br>{ <br>  // each node in the tree has member variables containing <br>  // all the data for a post except the body of the message<br>  public $m_postid;<br>  public $m_title;<br>  public $m_poster;<br>  public $m_posted;<br>  public $m_children;<br>  public $m_childlist;<br>  public $m_depth;<br><br>  public function __construct($postid, $title, $poster, $posted, $children, <br>                    $expand, $depth, $expanded, $sublist)<br>  { <br>    // the constructor sets up the member variables, but more <br>    // importantly recursively creates lower parts of the tree<br>    $this->m_postid = $postid;<br>    $this->m_title = $title;<br>    $this->m_poster = $poster;<br>    $this->m_posted = $posted;<br>    $this->m_children =$children;<br>    $this->m_childlist = array();<br>    $this->m_depth = $depth;<br><br>    // we only care what is below this node if it <br>    // has children and is marked to be expanded<br>    // sublists are always expanded<br>    if(($sublist||$expand) && $children)<br>    {<br>      $conn = db_connect();<br><br>      $query = "select * from header where parent = $postid order by posted";<br>      $result = $conn->query($query);<br><br>      for ($count=0; $row = @$result->fetch_assoc(); $count++)<br>      {<br>        if($sublist||$expanded[ $row['postid'] ] == true)<br>          $expand = true;<br>        else<br>          $expand = false;<br>        $this->m_childlist[$count]= new treenode($row['postid'],$row['title'],<br>                                      $row['poster'],$row['posted'],<br>                                      $row['children'], $expand,<br>                                      $depth+1, $expanded, $sublist);<br>      }<br>    }<br>  }  <br><br><br>  function display($row, $sublist = false)<br>  {<br>    // as this is an object, it is responsible for displaying itself<br><br>    // $row tells us what row of the display we are up to <br>    // so we know what color it should be<br><br>    // $sublist tells us whether we are on the main page<br>    // or the message page.  Message pages should have <br>    // $sublist = true.  <br>    // On a sublist, all messages are expanded and there are<br>    // no "+" or "-" symbols.<br><br>    // if this is the empty root node skip displaying<br>    if($this->m_depth>-1)  <br>    {<br>      //color alternate rows<br>      echo '<tr>
<td></td>      if ($row%2) <br>        echo "'#cccccc'>";<br>      else<br>        echo "'#ffffff'>";<br><br>      // indent replies to the depth of nesting<div class="clear">
                 
              
              
        
            </div>
</tr>
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn