Specifications

$query = “insert into header values
(‘“.$post[‘parent’].”’,
‘“.$post[‘poster’].”’,
‘“.$post[‘title’].”’,
0,
‘“.$post[‘area’].”’,
now(),
NULL
)”;
$result = mysql_query($query);
if (!$result)
{
return false;
}
// note that our parent now has a child
$query = “update header set children = 1 where postid = “.$post[‘parent’];
$result = mysql_query($query);
if (!$result)
{
return false;
}
// find our post id, note that there could be multiple headers
// that are the same except for id and probably posted time
$query = “select header.postid from header left
join body on header.postid = body.postid
where parent = ‘“.$post[“parent”].”’
and poster = ‘“.$post[“poster”].”’
and title = ‘“.$post[“title”].”’
and body.postid is NULL”;
$result = mysql_query($query);
if (!$result)
{
return false;
}
if(mysql_numrows($result)>0)
$id = mysql_result($result, 0, 0);
if($id)
{
$query = “insert into body values ($id, ‘“.$post[“message”].”’)”;
$result = mysql_query($query);
if (!$result)
{
Building Practical PHP and MySQL Projects
P
ART V
740
LISTING 29.13 Continued
35 7842 CH29 3/6/01 3:34 PM Page 740