Skip to content

Instantly share code, notes, and snippets.

Created August 10, 2014 00:11
Show Gist options
  • Save anonymous/3093e9027d05deb1197c to your computer and use it in GitHub Desktop.
Save anonymous/3093e9027d05deb1197c to your computer and use it in GitHub Desktop.
Instead of using a loop, you can combine the data into a single database query.
<?php
$userData = array();
foreach ($userList as $user) {
$userData[] = '("' . $user['first_name'] . '", "' . $user['last_name'] . '")';
}
$query = 'INSERT INTO users (first_name,last_name) VALUES' . implode(',', $userData);
mysql_query($query);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment