Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 2000051

Re: [PHP3] Add A Comment PHP Script From: Richard Lynch (richard <email protected>)
Date: 05/15/00

In article <391F291B.1A43BDCA <email protected>>, mesut <email protected> (Mesut TUNGA) wrote:

> Hi All,
>
> Is there any one know a examples add a comment php script for a current
> product.
>
> For example; users would submit comments for o product. And it will
> store on the same database which products stored.

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>

-- 
Richard Lynch                | If this was worth $$$ to you, buy a CD
US Customer Support Director | from one of the artists listed here:
Zend Technologies USA        | http://www.L-I-E.com/artists.htm
http://www.zend.com          | (this has nothing to do with Zend, duh!)

-- PHP 3 Mailing List <http://www.php.net/> To unsubscribe, send an empty message to php3-unsubscribe <email protected> To subscribe to the digest, e-mail: php3-digest-subscribe <email protected> To search the mailing list archive, go to: http://www.php.net/mailsearch.php3 To contact the list administrators, e-mail: php-list-admin <email protected>