title: Insert multiple rows into mysql with php using foreach arrays
body: <p>Im stuck, been trying to figure this out for 2 hours now. I have figured out the foreach loop, but cant figure out how to insert the data now.</p>
  
  <p>here is my php, what am I doing wrong?</p>
  
  <pre><code>    $query = "INSERT INTO images (thumb_path, image_path, main_image, project_id) VALUES ";  
  foreach($_POST as $key =&gt; $value) {
      $query .= "$thumb_path,$image_path,$main_image,$_POST[project_id])";
      $result = mysql_query($query, $connection);
  }
  </code></pre>
  
  <p>Thanks!</p>
  
  <p>Should I lay it out like this, sorry still a newbie to foreach and how it works.</p>
  
  <pre><code>foreach($_POST as $key =&gt; $value) {
      $query = "INSERT INTO images VALUES (thumb_path, image_path, main_image, project_id),";  
      $query .= "$value[thumb_path], $value[$image_path], $value[$main_image], '$_POST[project_id'])";
  }
  
  $result = mysql_query($query, $connection);
  </code></pre>