Hi All.
Can anyone help me out... I'm a little confused on the best approach to this solution. I'm generating a address update form which I populate from a DB select statement. The form contains address details (name, street, city, telephone etc) held in input text boxes:
<input type="text" name="surname" ...
Lets say the call returns 30 addresses, I generate a form containing 30 lines of address input text boxes. The user makes an update and I now want to write the changes back to the DB via an update statement. This is where my problems begin, as I've only ever coded a form that edits one record at a time and not multiple lines. Normally I would POST the details to $HTTP_POST_VARS array and then build the values into an update statement.
Different story with multiple address line as I'll have address fields per address line i.e. multiple input fields and values with the same field name e.g. surname
I've managed to work-out that I need to differenate between the multiple address lines. So I was going to add number to end of each field within a address row e.g.
surname1, street1, city1 ...
surname2, street2, city2 ...
surname3, street3, city3 ...
<input type="text" name="surname<?php echo $i; ?>"
as I can use the loop that generates the address lines.
This works great for populating the POST VARS array, as I get an array with all my values against keys with unique names. I tried using list and each inside a while loop to extract the data:
while (list ($key, $val) = each ($HTTP_POST_VARS))
But my difficulty starts when I try to extract the correct value by key name to build the update statement per address line... Basically I can't get a working version.
Can anyone suggest a better method of extracting the data or a different approach to submitting the data into the HTTP_POST_VARS array that's easier to manage when building the update statements.
Thanks in advance...
Chris