Bungholio
08-04-2003, 11:04 AM
Hi, thanks for looking,
Ive got a client with about 25 items on a form page like this:
<input name="prod1_desc" type="hidden" value="PhoneCard, $10.00">
<input name="prod1_price" type="hidden" value="9.50">
<input name="prod1_quantity" type="text" size=3 maxlength=5>
and it goes up prod2_..., prod3_... etc, etc till about 26
now i want to make a dynamic script for this, but dont know if the following will work (i get a parse error on the if statement)
$i = 1;
while ($i <= 26){
if (!$prod$i_quantity == "") {
$prod$i_subtotal = $prod$i_price * $prod$i_quantity;
echo ("Desc: ".$prod$i_desc.", Price: ".$prod$i_price.", Qnty: ".$prod$i_quantity.", Subtotal: ".$prod$i_subtotal."<br>");
}
$i++;
}
the idea is if they enter a quantity, then that product,price,qnty,total will be printed out.
this is just a temp script, ill have more complicated stuff then the echo probably, but what do you think ...?? maybe there is some funtion that i dont know about for this?? is it possible to use an $i for the number like that?
thanks,
Allan
Ive got a client with about 25 items on a form page like this:
<input name="prod1_desc" type="hidden" value="PhoneCard, $10.00">
<input name="prod1_price" type="hidden" value="9.50">
<input name="prod1_quantity" type="text" size=3 maxlength=5>
and it goes up prod2_..., prod3_... etc, etc till about 26
now i want to make a dynamic script for this, but dont know if the following will work (i get a parse error on the if statement)
$i = 1;
while ($i <= 26){
if (!$prod$i_quantity == "") {
$prod$i_subtotal = $prod$i_price * $prod$i_quantity;
echo ("Desc: ".$prod$i_desc.", Price: ".$prod$i_price.", Qnty: ".$prod$i_quantity.", Subtotal: ".$prod$i_subtotal."<br>");
}
$i++;
}
the idea is if they enter a quantity, then that product,price,qnty,total will be printed out.
this is just a temp script, ill have more complicated stuff then the echo probably, but what do you think ...?? maybe there is some funtion that i dont know about for this?? is it possible to use an $i for the number like that?
thanks,
Allan