Insert multiple data arrays & nbsp; (& nbsp; [0] & nbsp ;=& gt; & nbsp;/htdocs/uploads/resource/20121216145006_4246.docx & nbsp; [1] & nbsp ;=& gt; & nbsp;/htdocs/uploads/resource/20121216145 insert multiple data entries
Array ([0] =>/htdocs/uploads/resource/20121216145006_00006.docx [1] =>/htdocs/uploads/resource/20121216145006_5567.docx)
How can I insert two records into the database in the above array? [0], [1]
------ Solution --------------------
Foreach ($ arr as $ v ){
Mysql_query ("insert into talbe .....");
}
------ Solution --------------------
Reference:
Foreach ($ arr as $ v ){
Mysql_query ("insert into talbe .....");
}
This efficiency is too low, and it is better to generate an SQL statement.
------ Solution --------------------
Reference:
Reference: reference: foreach ($ arr as $ v ){
Mysql_query ("insert into talbe .....");
}
This efficiency is too low, and it is better to generate an SQL statement.
Please kindly advise!
If N records are written in this way, N insert statements are executed.
Insert into table_name (field1, field2 ,....)
VALUES
(Value1, value2 ,...),
(Value3, value4 ,...)....
You only need to execute it once.