Forum Moderators: coopster

Message Too Old, No Replies

Multiple mysql records from single form inputs

Form input has same fields multiple times

         

webwatch

2:50 pm on Sep 29, 2004 (gmt 0)

10+ Year Member



I am trying to develop a form which has the user inputing data in a columnar format. Each column has multiple fields (one for each row) there are 12 columns, I was able to submit to MySql database the first column fields. All subsequent columns would be the same field inputs but the values could be different. I need each column to be submitted to the database as a seperate record by using only one form submit. Is this possible and if so how can I make this happen?

Thanks in advance.

mincklerstraat

3:34 pm on Sep 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can make input fields that are arrays. So make each of these column values an array, and each of the rows will be array elements. Like:
<input name="last_name[]"><input name="first_name[]">

I believe the above works, though it's been a while since I've tried it. You'll have to try this yourself just to be sure. If not, it's easy enough to put incrementing numbers inside those brackets - last_name[1], first_name[1], last_name[2], first_name[2]. $_POST['last_name'] and other post values will then come through as arrays, use print_r($_POST) to check.