欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2024-02-06 13:02:52
...
php中论坛帖子展开,书本知识看不懂啊靠~,请帮帮我,
// 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
php中论坛帖子展开,书本知识看不懂啊靠~请帮帮小弟我

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频


网友评论

文明上网理性发言,请遵守 新闻评论服务协议

我要评论
  • php中论坛帖子展开,书本知识看不懂啊靠~请帮帮小弟我
  • 专题推荐

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

    认证0级讲师

    推荐视频教程
  • php中论坛帖子展开,书本知识看不懂啊靠~请帮帮小弟我javascript初级视频教程
  • php中论坛帖子展开,书本知识看不懂啊靠~请帮帮小弟我jquery 基础视频教程
  • 视频教程分类