Specifications
$query = “select * from header where parent = $postid order by posted”;
$result = mysql_query($query);
for ($count=0; $row = @mysql_fetch_array($result); $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 “<tr><td bgcolor = “;
if ($row%2)
echo “‘#cccccc’>”;
else
echo “‘#ffffff’>”;
// indent replies to the depth of nesting
for($i = 0; $i<$this->m_depth; $i++)
{
echo “<img src = ‘images/spacer.gif’ height = 22
width = 22 alt = ‘’ valign = bottom>”;
}
Building Practical PHP and MySQL Projects
P
ART V
726
LISTING 29.5 Continued
35 7842 CH29 3/6/01 3:34 PM Page 726