RE: [PHP] help with adding
| From: | Jesse Castro | Date: | Fri, 25 Feb 2005 18:00:26 +0000 |
| Subject: | RE: [PHP] help with adding | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-209416@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Jay Fitzgerald [mailto:jayfitz@bayou.com]
> Sent: Thursday, February 24, 2005 9:39 AM
> To: php-general@lists.php.net
> Subject: [PHP] help with adding
>
>
> I have messed with this for a couple of days and cant get it
> right. Maybe I need sleep :-)
>
>
>
> The code below is echoing the qty correctly (10, 5, 25)
>
>
>
> for ($i = 1; $i <= $sendnum; $i++)
>
> {
>
> $qty = $_POST['qty'.$i];
>
> echo $qty . '<br />';
>
> }
>
>
>
> The question is, how would I take add each of these numbers (10+5+25)?
>
>
>
> Any help is appreciated.
>
>
>
>
$total = 0;
for ($i = 1; $i <= $sendnum; $i++)
{
$qty = $_POST['qty'.$i];
echo $qty . '<br />';
$total = $total + $qty;
}
Hope that helps.
Jesse R. Castro