时间:2021-07-01 10:21:17 帮助过:7人阅读
// functions for loading, contructing and
// displaying the tree are 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, but 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 only care what is below this node if it
// has children and is marked to be expanded
// sublists are 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 this is an object, it is responsible for displaying itself
// $row tells us what row of the display we are 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 have
// $sublist = true.
// On a sublist, all messages are 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人气教程排行
- 174次 1 php如何获取跳转前的url
- 174次 2 php格林威治时间转换成当前时间的方法
- 174次 3 为什么php不能做大型系统?
- 174次 4 range函数怎么用
- 174次 5 php中计算页面加载时间几种方法总结_PHP教程
- 174次 6 求帮助,关于paypal支付返回值修改订单状态
- 174次 7 typecho怎么配置文章内容页?
- 174次 8 PhpStorm左侧structure不显示文件的方法列表是这么回事?
- 174次 9 查看PHP的环境变量_PHP
- 174次 10 PHP Primary script unknown 解决方法总结
- 174次 11 php的命名空间与自动加载实现方法
- 174次 12 解决laravel 出现ajax请求419(unknown status)的问题
- 173次 13 php 如何删除mysql记录
- 173次 14 PHP如何替换数组中的指定元素
- 173次 15 怎么去除字符串中非汉字、非字母、非数字的字符
- 173次 16 mysql如何一次执行多条SQL语句
- 173次 17 修改header里面的Connection为close解决方法
- 173次 18 PHP基于session.upload_progress 实现文件上传进度显示功能详解
- 173次 19 php5.6.x到php7.0.x特性小结
- 172次 20 php为什么会出现504错误