On Tue, Jan 15, 2013 at 9:08 PM, பத்மநாதன் <[email protected]> wrote:
> ILUGCs,
> I need an help to construct form for inserting multiple rows in
> single table in Mysql using PHP.
I am working on a script that has something along the similar lines.
I have used jQuery to handle ajax post request, which calls another
file that has mysql insert code.
One way to do is, create a two dimensional array
values = [
{
'column1' : 'value',
'column2' : 'value',
'column3' : 'value
},
{
'column1' : 'value',
'column2' : 'value',
'column3' : 'value'
}
]
Now to call the mysql script via ajax
$.ajax({
type: "POST",
url : 'mysql_script.php',
data : values,
success : function() {
//send success message to the user
}
error: functional() {
//send error message to the user
}
});
Now, in the mysql_script.php file store the parameter i.e. values in a
variable, loop over it and store it in the db
//Connect to MySQL
$values = $_POST['values']
foreach ($values as $value) {
$column1 = $value['column1'];
$column2 = $value['column2'];
$column3 = $value['column3'];
//MySQL insert query
}
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc