|
Posted by Richard Lynch on 02/25/05 20:29
Jay Fitzgerald wrote:
> 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)?
Search http://php.net for "variable variables" (Yes, really.)
It will let you turn 'qty' . $i into a new variable and get its value.
You probably should be using an ARRAY for qty anyway, though...
<input name="qty[product_id_47]">
<input name="qty[product_id_83]">
<input name="qty[product_id_99]">
Then you can use $_POST['qty'] as an array, and not mess around with
variable variables.
--
Like Music?
http://l-i-e.com/artists.htm
[Back to original message]
|