Counting With a For loop
Posted: Wed Jul 08, 2009 7:07 pm
Hi guys,
I now have a working for loop that prints / re-prints data from one form into this one. What iam trying to do now is count how much the total is within the $From_Pr array (this array contains prices). $Used is set by the user on the 1st php page which gets passed but this form.
For example, if the user enters 4, then there will be four different prices they would have entered into the form, this will now print back but i also want to display the total these four prices will add up to.
Thanks Glenn Curtis.
I now have a working for loop that prints / re-prints data from one form into this one. What iam trying to do now is count how much the total is within the $From_Pr array (this array contains prices). $Used is set by the user on the 1st php page which gets passed but this form.
For example, if the user enters 4, then there will be four different prices they would have entered into the form, this will now print back but i also want to display the total these four prices will add up to.
Thanks Glenn Curtis.
Code: Select all
for ($i=1; $i<=$Used; $i++) {
print ("<input type=\"text\" name=\"Form_In[$i]a\" class=\"Invoice_Items\" value=\"$Form_In[$i]\" />\n");
print ("<input type=\"text\" name=\"Form_Pr[$i]a\" class=\"Invoice_Prices\" value=\"£ $Form_Pr[$i]\" /><br>\n");
//print ("<br><br><br>$Form_Pr[$i]");
$Total = $Form_Pr[$i] + $Form_Pr[$i];
}
print ("Total = $Total");