title: Multiple Image Upload using PHP into MYSQL database
body: <p>I am currently very puzzled over why I am unable to insert an array of images over into my database.
  As of now, my current multiple file upload is able to upload images into my default directory, and able to store ONLY the first image into my SQL server database, why is this so? Shouldn't the foreach command be able to split all the multiple file that i upload and store them respectively into the database? Please shed some lights on this, thank you!</p>
  
  <p>HTML Code</p>
  
  <pre><code>&lt;form method="post" enctype="multipart/form-data"  action=""&gt;  
      &lt;input type="file" name="files[]" id="files" multiple /&gt;  
      &lt;br /&gt;&lt;br /&gt;
      &lt;button type="submit"&gt;Upload selected files&lt;/button&gt;  
  </code></pre>
  
  <p>PHP Code</p>
  
  <pre><code>foreach ($_FILES["files"]["error"] as $key =&gt; $error) {
          if ($error == UPLOAD_ERR_OK) {
              $name = $_FILES["files"]["name"][$key];
              move_uploaded_file($_FILES["files"]["tmp_name"][$key], "" . $_FILES['files']['name'][$key]);
              $sql = "INSERT INTO `test`(`image`) VALUES ('" . $name . "')";
              $result = mysqli_query($connection, $sql);
              echo "The file " . basename($_FILES['multiple_uploaded_files']['name']) . " has been uploaded";
          } else {
              echo "There was an error uploading the file, please try again!";
          }
      }
  </code></pre>
  
  <p>Cheers,
  A tech newbie learning in progress.</p>