HELP! Need to insert multiple rows into a database table
Posted: Wed Jun 10, 2009 3:33 am
Ok so I have built this form and it contains 3 rows with the same information asked. The user should have the option to fill out one, two, or all three rows.
Upon submission I want each row of form data to be entered into seperate database table rows. Myd DB is MYSQL 5.1.33 and i'm using php5
Here is my form
my real problem comes my insert.php document. This is what I have for the insert query and i'm positive that it's wrong. PLEASE HELP
Upon submission I want each row of form data to be entered into seperate database table rows. Myd DB is MYSQL 5.1.33 and i'm using php5
Here is my form
Code: Select all
<form action="insert.php" method="post" >
<td height="63" colspan="5"><h3>Other involvement during high school, college (clubs, sports, work, volunteer, etc.): </h3></td>
</tr>
<td width="13%" height="60"><h3>#</h3></td>
<td width="20%"><h3>Activity</h3></td>
<td width="19%"><h3>Position</h3></td>
<td width="23%"><h3>Start Date</h3></td>
<td width="25%" height="60"><h3>End Date</h3></td>
</tr>
<tr>
<td height="63"><label for="InvolvementID"></label>
<input name="ID1" type="text" id="ID1" size="6" /></td>
<td height="63"><label for="Activity1"></label>
<input name="Activity1" type="text" id="Activity1" size="15" /></td>
<td height="63"><label for="Position1"></label>
<input name="Position1" type="text" id="Position1" size="15" /></td>
<td height="63"><label for="StartDate1"></label>
<input name="StartDate1" type="text" id="StartDate1" size="15" /></td>
<td height="63"><label for="EndDate1"></label>
<input name="EndDate1" type="text" id="EndDate1" size="15" /></td>
</tr>
<tr>
<td height="63"><input name="ID2" type="text" id="ID2" size="6" /></td>
<td height="63"><input name="Activity2" type="text" id="Activity2" size="15" /></td>
<td height="63"><input name="Position2" type="text" id="Position2" size="15" /></td>
<td height="63"><input name="StartDate2" type="text" id="StartDate2" size="15" /></td>
<td height="63"><input name="EndDate2" type="text" id="EndDate2" size="15" /></td>
</tr>
<tr>
<td height="62"><input name="ID3" type="text" id="ID3" size="6" /></td>
<td height="62"><input name="Activity3" type="text" id="Activity3" size="15" /></td>
<td height="62"><input name="Position3" type="text" id="Position3" size="15" /></td>
<td height="62"><input name="StartDate3" type="text" id="StartDate size=" size="15"15" /></td>
<td height="62"><input name="EndDate3" type="text" id="EndDate3" size="15" /></td>
</form>Code: Select all
$involv= foreach ($_POST['ID']) )
{mysql_query("INSERT INTO Involvement (ID,Activity, Position. StartDate, EndDate)
VALUES ('$_POST[ID];''$_POST[Activity];','$_POST[Position];','$_POST[StartDate];','$_POST[EndDate];')";