Need help INSERT record(s) MySQL DB

Posted by JM4 on Stack Overflow See other posts from Stack Overflow or by JM4
Published on 2010-05-26T20:03:46Z Indexed on 2010/05/26 20:21 UTC
Read the original article Hit count: 146

Filed under:
|
|
|
|

I have an online form which collects member(s) information and stores it into a very long MySQL database. We allow up to 16 members to enroll at a single time and originally structured the DB to allow such.

For example:

If 1 Member enrolls, his personal information (first name, last name, address, phone, email) are stored on a single row.

If 15 Members enroll (all at once), their personal information are stored in the same single row.

The row has information housing columns for all 'possible' inputs. I am trying to consolidate this code and having every nth member that enrolls put onto a new record within the database.

I have seen sugestions before for inserting multiple records as such:

INSERT INTO tablename VALUES (('$f1name', '$f1address', '$f1phone'), ('$f2name', '$f2address', '$f2phone')...

The issue with this is two fold:

  1. I do not know how many records are being enrolled from person to person so the only way to make the statement above is to use a loop
  2. The information collected from the forms is NOT a single array so I can't loop through one array and have it parse out. My information is collected as individual input fields like such: Member1FirstName, Member1LastName, Member1Phone, Member2Firstname, Member2LastName, Member2Phone... and so on

Is it possible to store information in separate rows WITHOUT using a loop (and therefore having to go back and completely restructure my form field names and such (which can't happen due to the way the validation rules are built.)

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql