php中论坛帖子展开,书本知识看不懂啊靠~请帮帮小弟我
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php中论坛帖子展开,书本知识看不懂啊靠~请帮帮小弟我,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2372字,纯文字阅读大概需要4分钟。
内容图文
php中论坛帖子展开,书本知识看不懂啊靠~,请帮帮我,<?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 '<td bgcolor = ';
if ($row%2)
echo "'#cccccc'>";
else
echo "'#ffffff'>";
// indent replies to the depth of nesting
内容总结
以上是互联网集市为您收集整理的php中论坛帖子展开,书本知识看不懂啊靠~请帮帮小弟我全部内容,希望文章能够帮你解决php中论坛帖子展开,书本知识看不懂啊靠~请帮帮小弟我所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。
来源:【匿名】