gilbertsavier Posted July 13, 2009 Report Share Posted July 13, 2009 (edited) Hi, I have a form that asks the applicant for previous involvement. They have the option of entering up to three rows and after they press submit the computer needs to enter possible multiple rows. Here is my form code: Other involvement during high school, college (clubs, sports, work, volunteer, etc.): Activity Position Start Date End Date Here is the insert1.php file <?php $con = mysql_connect("localhost","Application","*******"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("CpaApp", $con); //Assign each array to a variable foreach($_POST['Activity'] as $row=>$Act) { $Activity=$Act; $Position=$_POST['Position'][$row]; $StartDate=$_POST['StartDate'][$row]; $EndDate=$_POST['EndDate'][$row]; } //enter rows into database foreach($_POST['Activity'] as $row=>$Act) { $Activity=mysql_real_escape_string($Act); $Position=mysql_real_escape_string($_POST['Position'][$row]); $StartDate=mysql_real_escape_string($_POST['StartDate'][$row]); $EndDate=mysql_real_escape_string($_POST['EndDate'][$row]); } $involv = "INSERT INTO Involvement (Activity, Position, StartDate, EndDate) VALUES ('.$Activity.','.$Position.','.$StartDate.','.$EndDate.')"; if (!mysql_query($involv,$con)) { die('Error: ' . mysql_error()); } echo "$row record added"; mysql_close($con) ?> ------------------------------- Thanks & regards Lokananth [Link Deleted] Edited July 13, 2009 by Andrea Quote Link to comment Share on other sites More sharing options...
Korken Posted July 13, 2009 Report Share Posted July 13, 2009 Is this what you wanted? Then will each one beome it's own row in the database. Hope it helps. foreach($_POST['Activity'] as $row=>$Act) { $Activity = mysql_real_escape_string($Act); $Position = mysql_real_escape_string($_POST['Position'][$row]); $StartDate = mysql_real_escape_string($_POST['StartDate'][$row]); $EndDate = mysql_real_escape_string($_POST['EndDate'][$row]); $involv = "INSERT INTO Involvement(Activity, Position, StartDate, EndDate) VALUES('$Activity', '$Position', '$StartDate', '$EndDate')"; mysql_query($involv); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.