PHP: saving multiple tuples to the same table

Posted by Binaryrespawn on Stack Overflow See other posts from Stack Overflow or by Binaryrespawn
Published on 2010-03-08T00:52:29Z Indexed on 2010/03/08 1:01 UTC
Read the original article Hit count: 271

Filed under:
|

Hi all, I am trying to save data into the same table several times from the same $_POST array. You see, on my registration form a family is allowed to specify the names, gender and age of all members they wish to bring along.

This data is being stored in a database table called aditional_member. Based on family size, I am dynamically generating html table rows where each row has the number of input fields required.

<tr id="additionalmember_3">
    <td><input type="text" name="first_name1" maxlength="50" value="" /></td>
    <td><input type="text" name="last_name1" maxlength="50" value="" /></td>
    td><select name="gender1" value="" ><option value='Male'>Male</option><option value='Female'>Female</option></select></td>
    <td><select name="age_group"value="" ><option value='18 to 30'>18 to 30</option><option value='31 to 60'>31 to 60</option></select></td>      
</tr>

When I POST, let us say I have three sets of input(3 table rows as above), Is there a simple way to insert into the addional_member table the data from row one, then row two, and so on. I tried looping the insert statement, which failed. I am basically open to suggestions, I do not need to use a table.

Any ideas, Thank you.

© Stack Overflow or respective owner

Related posts about php

Related posts about insert