RE: [PHP] MySQL insert
| From: | Jason Wong | Date: | Wed, 06 Sep 2000 04:57:27 +0000 |
| Subject: | RE: [PHP] MySQL insert | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-15437@lists.php.net to get a copy of this message | ||
Why not calculate total first?
$total = $points+($rebounds*2)+($assists*2);
$sql = "INSERT INTO players (fname, lname, points, rebounds, total)
VALUES ('$fname', '$lname', '$points', '$rebounds',
'$total')";
-
Jason Wong
Digital View Ltd
2201 Nanyang Plaza
57 Hung To Road
Kwun Tong
HONG KONG
Tel: +852-2861-3615
Fax: +852-2520-2987
www.digitalview.com
> -----Original Message-----
> From: Jason Murray [mailto:Jason.Murray@melbourneit.com.au]
> Sent: 06 September 2000 13:36
> To: 'Scott Webb'; php-general@lists.php.net
> Subject: RE: [PHP] MySQL insert
>
> $sql = "INSERT INTO players (fname, lname, points, rebounds, total)"
> ."VALUES ('$fname', '$lname', '$points', "
> ."'".($points+($rebounds*2)+($assists*2)."')";
>
> If your total column is a text field, this will work. If it's
> not a text
> field, you'll need to eliminate the '' marks around the line
> that calculates
> the total. Basically, you can't calculate inside an echo "",
> you need to
> escape the " marks.
>
> Jason
>