Need Help adding up prices.
Posted: Thu Jan 26, 2006 1:02 pm
Hello,
I am trying to figure out how to add up the total cost of my accessories, and assign it to the value of $total_accessory_cost. Then add that cost with 2 other values. I can add the other two no problem, because they are just plain input box's. The accessories are different because they are in an array, and I don't know how to have it say add up $price_$i then assign it to a value.
here is my code that submits the information:
On the next page I only have this so far because I don't even know where to start with the accessories.
I am trying to figure out how to add up the total cost of my accessories, and assign it to the value of $total_accessory_cost. Then add that cost with 2 other values. I can add the other two no problem, because they are just plain input box's. The accessories are different because they are in an array, and I don't know how to have it say add up $price_$i then assign it to a value.
here is my code that submits the information:
Code: Select all
<?PHP
$field_count = $_POST['field_count'];
for($i= 1;$i <= $field_count;++$i)
{
echo "
<tr>
<td align=left width=90><input type=text size=10 name=\"model_$i\" value=\"".$_POST['model_'.$i]."\"></td>
<td align=left width=90><input type=text size=40 name=\"description_$i\" value=\"".$_POST['description_'.$i]."\"></td>
<td align=right>$<input type=text size=10 name=\"price_$i\" value=\"".$_POST['price_'.$i]."\"></td>
</tr> ";
};
?>On the next page I only have this so far because I don't even know where to start with the accessories.
Code: Select all
<?PHP
$total_equipment_cost = $_POST['machine_base_price'] + $_POST['surge_price'] + $total_accessory_cost ;
?>