I've found some answers to my problem on this forum, but not exactly the answer I was looking for. Sorry if I've missed something.
This is my situation:
I am trying to make an insertion into an MySQL table, using an array for the field list AND another array for the values. I know by know that you can't just use:[code=mysql]INSERT INTO table_name ($array1) VALUES ($array2);[/code]
So i've stripped the arrays first. My problem however is that I can only strip one array at the time, so this:[php]foreach ($array as $value)
mysql_query("IN SERT INTO table_name VALUES ($array)");[/php]would work, but how can I define the field names, wich are also in a array?
I tried the following, but it doesn't work (didn't really expect it to also)
[php]foreach ($array1 as $value)
foreach ($array2 as $value)
INSERT INTO table_name ($array1) VALUES ($array2);[/php]
I hope you understand this poor explanation. Also, I wasn't sure where to post it (PHP or MySQL), but since my problem seemed more of a PHP issue I thought i'd start here.
This is my situation:
I am trying to make an insertion into an MySQL table, using an array for the field list AND another array for the values. I know by know that you can't just use:[code=mysql]INSERT INTO table_name ($array1) VALUES ($array2);[/code]
So i've stripped the arrays first. My problem however is that I can only strip one array at the time, so this:[php]foreach ($array as $value)
mysql_query("IN SERT INTO table_name VALUES ($array)");[/php]would work, but how can I define the field names, wich are also in a array?
I tried the following, but it doesn't work (didn't really expect it to also)
[php]foreach ($array1 as $value)
foreach ($array2 as $value)
INSERT INTO table_name ($array1) VALUES ($array2);[/php]
I hope you understand this poor explanation. Also, I wasn't sure where to post it (PHP or MySQL), but since my problem seemed more of a PHP issue I thought i'd start here.
Comment