My Problem - For Loops / Forms
Posted: Wed Jul 08, 2009 7:55 am
Hi guys, hope you can help becuase this problem is doing my head in!!
I have a form of 20 different inputs, text and price, this form is linked to another php page which i wish to look up how many inputs have been used, and then print them. Below is the code that is on the second php page.
$Used is on the form on the 1st page and the user enters how many fields they are going to use.
$Form_In / $Form_Pr - these are the inputs on the form, In is the text input, and Pr would be price.
Each Form_In / Form_Pr is set with a number after it, e.g. Form_In1, Form_In2, Form_Pr1, Form_Pr2, ect.
I hope someone can help, as with this for loop i am trying to get the number after the In/Pr to be printed automaticlly, so that i dont need to reprint all 20 fields when only 3 are used.
But this dont work, it will only print the number contain within, $i - not add the number to the $From_In - please what am i doing wrong?
Thanks Glenn Curtis.
I have a form of 20 different inputs, text and price, this form is linked to another php page which i wish to look up how many inputs have been used, and then print them. Below is the code that is on the second php page.
$Used is on the form on the 1st page and the user enters how many fields they are going to use.
$Form_In / $Form_Pr - these are the inputs on the form, In is the text input, and Pr would be price.
Each Form_In / Form_Pr is set with a number after it, e.g. Form_In1, Form_In2, Form_Pr1, Form_Pr2, ect.
I hope someone can help, as with this for loop i am trying to get the number after the In/Pr to be printed automaticlly, so that i dont need to reprint all 20 fields when only 3 are used.
But this dont work, it will only print the number contain within, $i - not add the number to the $From_In - please what am i doing wrong?
Thanks Glenn Curtis.
Code: Select all
<form id="form1" name="form1" method="post" action="XX">
<?php
$Used = $Form_Used;
print ("Number entered in on used: $Used<br><br>");
for ($i=1; $i<=$Used; $i++) {
print ("I is : $i<br><br>");
print ("$Form_In$i");
}
?>
<br /><br /><input name="Submit" type="submit" value="Submit" />
</form>