Passing multiple data from a form to a php page
Posted: Sun May 11, 2003 7:51 pm
I have a form with 3 text fields and a button that you use to extend the form and give you another 3 text fields below it for the same information and so on with the button... my problem is how do I total these fields? When i fill them in and hit submit (say I have 2 rows worth) it only displays the final rows values.
echo "<tr><TD> <input type = 'text' name = 'name'/></td> <td> <input type = 'text' name = 'type'/> <td> <input type = 'text' name = 'cost'/> </td></tr>";
I know its because it keeps using the same names over and over each time they add a row and overwriting the old data.. but how can I make it like into an array because its html and instead use php.. how can you edit those variables so that its like name = 'name[0]' name='name[1]' and so on instead of name = 'name'. Or is there another way to do this?
on the target php file it just takes the variables and displays them or its supposed to add them up but I only get the last field row of values
$name = $_POST['name'];
echo "<h2>$name</h2>";
eg.
form text fields
row1 name = bob type = blah cost = 10
row2 name = smith type = f cost = 3
so I'm only getting the row 2 values or if I added row 3 i'd only get row 3 values
echo "<tr><TD> <input type = 'text' name = 'name'/></td> <td> <input type = 'text' name = 'type'/> <td> <input type = 'text' name = 'cost'/> </td></tr>";
I know its because it keeps using the same names over and over each time they add a row and overwriting the old data.. but how can I make it like into an array because its html and instead use php.. how can you edit those variables so that its like name = 'name[0]' name='name[1]' and so on instead of name = 'name'. Or is there another way to do this?
on the target php file it just takes the variables and displays them or its supposed to add them up but I only get the last field row of values
$name = $_POST['name'];
echo "<h2>$name</h2>";
eg.
form text fields
row1 name = bob type = blah cost = 10
row2 name = smith type = f cost = 3
so I'm only getting the row 2 values or if I added row 3 i'd only get row 3 values