title: html php file upload sorting / order
body: <p>I have the following html code to upload a maximum of 8 images:</p>
  
  <pre><code>&lt;div class="form-group"&gt;
  &lt;label class="col-sm-3 control-label"&gt;img 1&lt;/label&gt;
      &lt;div class="col-sm-6"&gt;
          &lt;input type="file" name="img1" /&gt;
      &lt;/div&gt;
   &lt;/div&gt;
   &lt;div class="form-group"&gt;
   &lt;label class="col-sm-3 control-label"&gt;img 2&lt;/label&gt;
       &lt;div class="col-sm-6"&gt;
           &lt;input type="file" name="img2" /&gt;
       &lt;/div&gt;
   &lt;/div&gt;
   ...... same for img3,4,5,6,8      
  </code></pre>
  
  <p>php code</p>
  
  <pre><code>if (array_key_exists('img1', $_FILES)) {
     if (in_array('image/jpg', $_FILES['img1']) &amp;&amp; $_FILES['img1']['error'] == '0') {
        $img1 = "http://www.*.com/tmp/".$findid."_1.jpg";
        $name1 = $findid."_1.jpg";             
        move_uploaded_file($_FILES['img1']['tmp_name'], 'tmp/'.$name1);
     }
  } 
  ...... same for img2,3,4,5,6,8   
  
  &lt;?php 
  $images = explode(';', $ad['images']);
  if ($images != NULL) {
     foreach ($images as $i =&gt; $filename) {
     echo '&lt;a href="'.$filename.'" target="_blank" &gt;&lt;img src="'.$filename.'" width="60px" height="55px" style="float:left; border:1px solid #B1C4DF;" /&gt;&lt;/a&gt;';
     }
  }
  ?&gt;
  
  $images = implode(";",array_filter(array($img1,$img2,$img3,$img4,$img5,$img6,$img7,$img8)));
    if (isset($_GET['type']) &amp;&amp; $_GET['update'] == 'true') {
        if($images != null){
          mysql_query("UPDATE ads SET title ='$title', images ='$images', description ='$description', priceValue ='$priceValue' WHERE id = '" . $_GET['id'] . "'") OR die(mysql_error());
          updateImages($un,$pw,$_GET['id'],$images);
        }else{
          mysql_query("UPDATE ads SET title ='$title', description ='$description', priceValue ='$priceValue' WHERE id = '" . $_GET['id'] . "'") OR die(mysql_error()); 
        }
  
        header("Location: edit.php?type=edit&amp;id=" . $_GET['id'] . "");
    }
  </code></pre>
  
  <p>the problem is when I only upload img2 and save the form other existing images are removed from the database. When I upload img1 and img2 everything is fine. How can I edit the php code so it is possible to only upload img3 for example and retain img 1 and img2 ?</p>