Specifications
//get all header information from ‘header’
$query = “select title from header where postid = $postid”;
$result = mysql_query($query);
if(mysql_numrows($result)!=1)
return “”;
return mysql_result($result, 0, 0);
}
LISTING 29.10 get_post_message() Function from discussion_fns.php—Retrieves a
Message’s Body from the Database
function get_post_message($postid)
{
// extract one post’s message from the database
if(!$postid) return “”;
$conn = db_connect();
$query = “select message from body where postid = $postid”;
$result = mysql_query($query);
if(mysql_numrows($result)>0)
{
return mysql_result($result,0,0);
}
}
These first two functions retrieve an article’s header and body (respectively) from the database.
LISTING 29.11 add_quoting() Function from discussion_fns.php—Indents a Message Text
with “>” Symbols
function add_quoting($string, $pattern = “> “)
{
// add a quoting pattern to mark text quoted in your reply
return $pattern.str_replace(“\n”, “\n$pattern”, $string);
}
The add_quoting() function reformats the string to begin each line of the original text with a
symbol, which defaults to >.
Building Web Forums
C
HAPTER 29
29
BUILDING WEB
FORUMS
737
LISTING 29.9 Continued
35 7842 CH29 3/6/01 3:34 PM Page 737