redho home | products | services

Programming Forums


Community for Java, PHP, Perl C, ASP and Python programmers
Tuesday 18 September 2018 21:31

Ask your IT question here

Insert Multiple Rows Into A Mysql Table Using Php Array



 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Programming Forums -> PHP programming forum
View previous topic :: View next topic  
Author Message
gilbertsavier
New Programmer


Joined: 02 Jul 2009
Posts: 21
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:

<form>
<table>
<td><h3>Other involvement during high school, college (clubs, sports, work, volunteer, etc.): </h3></td>
</tr>
<tr>
<td><h3>Activity</h3></td>
<td><h3>Position</h3></td>
<td><h3>Start Date</h3></td>
<td><h3>End Date</h3></td>
</tr>
<tr>

<td><input>
<td><input>
<td><input>
<td><input>
</tr>
<tr>

<td><input>
<td><input>
<td><input>
<td><input>
</tr>
<tr>

<td><input>
<td><input>
<td><input>
<td><input>
</table>
<p>&nbsp;</p>
<p>

<input>

</p>
</form>



Here is the insert1.php file
<php>$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

Live Chat Software By miOOt

Reply with quote
 
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Programming Forums -> PHP programming forum


Dubai Forums - Expat Help | Vegan Forum | Java Programming | 3d Design Resources | 3d Forum | 3D Jobs | 3D Textures | Paris Forum | Europe Forum
Dubai Classifieds | Dubai Property | Jobs in Dubai | Free London Classifieds | Jobs in London UK

High Quality, Custom 3d animation and Web Design solutions Royal Quality Web Hosting Services Vegetarian and Animal Rights news

© 2018 RedHo