...

INserting into MySQL from an array

operandi
10-01-2002, 03:01 PM
Hi

Is there a way of inserting rows into MySQL from a PHP array. I know that I can do this:

foreach ( $array as $val )
{
run an insert query for $val
}

however that creates many queries. Is there are smarter way ie performing only one insert query for all values of the array?

Thanks, in advance

Alekz
10-01-2002, 03:05 PM
Hi,
I think the answer is NO :(
However You can build a single string containing all the subsequent INSERT's delimited with ; and then execute a single mysql_query()...

Alex

operandi
10-01-2002, 06:33 PM
I took your advice and created a comma delimited string instead - thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum