joined:Aug 18, 2008
Though I've never used multiple VALUES lists within INSERT statements myself, they say it's possible and much quicker than multiple individual INSERT statements. Speed of INSERT statements
• If you are inserting many rows from the same client at the same time, use INSERT statements with multiple VALUES lists to insert several rows at a time. This is considerably faster (many times faster in some cases) than using separate single-row INSERT statements. INSERT syntax
INSERT statements that use VALUES syntax can insert multiple rows. To do this, include multiple lists of column values, each enclosed within parentheses and separated by commas. Example:
INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);
The values list for each row must be enclosed within parentheses.
Actually, now that I know this it will make a project of mine which I was dreading much quicker and easier too.
So, for your case, each time the loop runs push the values as a string into an existing array (pseudo example php code):
You may need to play with quote marks and such, make sure strings are quoted and properly cleansed of course.
Then when you've collected all the values and are ready to make your single INSERT statement,
$query = 'INSERT into the_table_name (name, number, address, phone_number) VALUES '.implode(',', $my_VALUES_array)
$resutl = mysql_query($query)