PHP forum posts, book Knowledge can not understand AH rely on ~ please help me

Source: Internet
Author: User
PHP forum posts, books knowledge can not understand AH rely on ~, please help me,
 Functions for loading, contructing and
Displaying the tree is in this file

Class TreeNode
{
Each node in the tree has member variables containing
All the data for a post except the body of the message
Public $m _postid;
Public $m _title;
Public $m _poster;
Public $m _posted;
Public $m _children;
Public $m _childlist;
Public $m _depth;

Public function __construct ($postid, $title, $poster, $posted, $children,
$expand, $depth, $expanded, $sublist)
{
The constructor sets up the member variables, and more
Importantly recursively creates lower parts of the tree
$this->m_postid = $postid;
$this->m_title = $title;
$this->m_poster = $poster;
$this->m_posted = $posted;
$this->m_children = $children;
$this->m_childlist = Array ();
$this->m_depth = $depth;

We are below this node if it
Has children and was marked to be expanded
Sublists is always expanded
if ($sublist | | $expand) && $children)
{
$conn = Db_connect ();

$query = "SELECT * from header where parent = $postid ORDER by posted";
$result = $conn->query ($query);

for ($count =0; $row = @ $result->fetch_assoc (); $count + +)
{
if ($sublist | | $expanded [$row [' PostID ']] = = true)
$expand = true;
Else
$expand = false;
$this->m_childlist[$count]= New TreeNode ($row [' PostID '], $row [' title '],
$row [' poster '], $row [' posted '],
$row [' Children '], $expand,
$depth +1, $expanded, $sublist);
}
}
}


function display ($row, $sublist = False)
{
As is a object, it is responsible for displaying itself

$row tells us what row of the display we is up to
So we know what color it should be

$sublist tells us whether we are on the main page
or the Message page. Message pages should has
$sublist = True.
On a sublist, all messages is expanded and there are
No "+" or "-" symbols.

If this is the empty root node skip displaying
if ($this->m_depth>-1)
{
Color alternate rows
Echo '";
Else
echo "' #ffffff ' >";

Indent replies to the depth of nesting
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.