Do not use queries in loop 
Many times a programmer make his web page slow by using the wrong way of using queries. Like “Using Queries in Loop“;
For example -
foreach ($userList as $user) 
{
  $query = 'INSERT INTO users (first_name,last_name) 
  VALUES("' . $user['first_name'] . '", "' . $user['last_name'] . '")';
  mysql_query($query);
  }
It will result -
INSERT INTO users (first_name,last_name) VALUES("John", "Doe") in loop.
 
But we can use loop in a different way , see-
 
$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);
 It will result-
INSERT INTO users (first_name,last_name) VALUES(“John”, “Doe”),(“Jane”, “Doe”)…
 The later one is obviously better and faster.