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

WBOY
Lepaskan: 2016-06-13 11:59:41
asal
1014 orang telah melayarinya

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>
Salin selepas log masuk
Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!