I’m creating a form where a user can enter their address history, when they land on the page they will be able to enter their postcode which will search postcode anywhere and select their address from the results which will then populate the following hidden fields – house_name, address1, town and county.
They will then have the ability to add as many other addresses as they wish until they have completed 5 years address history.
Is the best way to give the fields an array for their name e.g postcode[], house_name[], address1[], town[] and county[] with the additional addresses the same or to give them all unique names e.g postcode_1, house_name_1 etc then the next address postcode_2, house_name_2 etc?
Also, how would I get the postcode value from each for me to use to lookup postcode anywhere?
If I get what you mean it would probably be best to store it in a 2 dimensional array:
for example:
That way you can easily loop over each item and put it in the db.
PS, this would be prefered: