|
Posted by Mark on 02/24/06 11:16
relevant code:
// submit comment
if( $name && $comment )
{
$query = "INSERT INTO comments (name,email,comment,id) VALUES
('$name','$email','$comment',$id)";
mysql_query($query,$db);
}
else if( $submit )
{
echo 'missing fields';
}
// display comments
$result = mysql_query("SELECT * FROM comments WHERE id='$id' ORDER BY
timestamp DESC");
$num = mysql_numrows($result);
for($i=0; $i<$num; $i++)
{
$name = mysql_result($result,$i,"name");
$email = mysql_result($result,$i,"email");
$comment = mysql_result($result,$i,"comment");
echo '<br />';
if( $email )
echo '<a href="mailto:'.$email.'">';
echo '<b>'.$name.':</b>';
if( $email )
echo '</a>';
echo '<br />'.$comment;
}
mysql_close();
// display form
echo '
<form action="?id='.$id.'" method="POST">
<label for="name">Name</label>
<input name="name" type="text" /><br />
<label for="email">Email</label>
<input name="email" type="text" /><br />
<label for="comment">Comment</label>
<textarea name="comment"></textarea><br />
<input name="submit" type="submit" value="Submit" />
</form>
';
Navigation:
[Reply to this message]
|