Specifications
echo “<br><br>”;
display_replies_line();
display_tree($expanded, 0, $postid);
}
do_html_footer();
?>
This script uses three main function calls to do its job: get_post(), display_post(), and
display_tree().
The get_post() function pulls the function details out of the database. The code for this func-
tion is shown in Listing 29.7.
LISTING 29.7 get_post() Function from discussion_fns.php—Retrieves a Message from
the Database
function get_post($postid)
{
// extract one post from the database and return as an array
if(!$postid) return false;
$conn = db_connect();
//get all header information from ‘header’
$query = “select * from header where postid = $postid”;
$result = mysql_query($query);
if(mysql_numrows($result)!=1)
return false;
$post = mysql_fetch_array($result);
// get message from body and add it to the previous result
$query = “select * from body where postid = $postid”;
$result2 = mysql_query($query);
if(mysql_numrows($result2)>0)
{
$body = mysql_fetch_array($result2);
if($body)
{
$post[‘message’] = $body[‘message’];
}
}
return $post;
}
Building Web Forums
C
HAPTER 29
29
BUILDING WEB
FORUMS
733
LISTING 29.6 Continued
35 7842 CH29 3/6/01 3:34 PM Page 733