You can use a for loop to operate on each element of the array. I'm assuming it's a one (meaningful) columned table.
//len is length of array
for (i=0; 0<len; i++){
//create SQL statement
sql="INSERT INTO table (row1) VALUES " . array[i];
//[execute sql here]
}
Alternatively, you could do it like so, if it will work with your version of SQL:
//all inserts are done in the one SQL statement
int len = //length of array
//the start of the statement. The first element is done here because
//one less comma is required then the number of elements
string sql = "INSERT INTO table (row1) VALUES (" . array[0];
for (int i=1; 0<len; i++){
//create SQL statement
sql .= "), VALUES (" . array[i];
}
sql .= ");";
//[execute sql here]
http://en.wikipedia.org/wiki/Insert_(SQL)
Last edited by humbug; Jun 7th, 2009 at 12:27 am. Reason: found better solution
Reputation Points: 20
Solved Threads: 13
Junior Poster in Training
Offline 93 posts
since Oct 2005