Untested code off the top of my head:
CREATE table comments(
productid int4,
comment text
);
product.php3
<?php
$productid = 42;
$product_name = 'widget';
echo "<A HREF=comment.php3?productid=$productid>Comments</A> about $product_name<BR>n";
$comments = mysql_query("select comment from comments where productid = $productid") or die(mysql_error());
while (list($comment) = mysql_fetch_row($comments)){
echo $comments, "<HR>";
} ?>
comment.php3
<?php
if (isset($submit)){
mysql_query("INSERT into comments(productid, comment) values($productid, '$comments')") or die(mysql_error());
echo "Thank you for your comment.<BR>n";
} ?> <FORM ACTION=comment.php3 METHOD=POST>
<TEXTAREA NAME=comments WRAP=VIRTUAL></TEXTAREA><BR>
<INPUT TYPE=SUBMIT NAME=submit>
</FORM>
|
|