Update an image with one by one
<p>I want to update image in one by one.</p>

<p>Example : I want to update only IMG1.</p>

<p><a href="https://i.stack.imgur.com/xzVIG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xzVIG.jpg" alt="enter image description here"></a></p>

<p>img1 : <code>img_id = 1, img_name = demo1.jpg</code></p>

<p>img2 : <code>img_id = 2, img_name = demo2.jpg</code></p>

<p>When I press update button with only IMG1 it should send <code>img_id = 1</code> to <code>$id = $_POST['image_id'];</code> But it send <code>img_id = 2</code> Then will make IMG2 has been update not IMG1.</p>

<p>updateimage.php</p>

<pre><code>&lt;div class="col-md-4 col-sm-6 col-xs-12"&gt;
   &lt;div class="text-center"&gt;
      &lt;?php $result = mysql_query("SELECT img_id, img_name FROM fm_product_image WHERE p_id_img = '$ID'")or die(mysql_error()); ?&gt;
      &lt;?php while ($imagerows = mysql_fetch_array($result)) { $imgid = $imagerows['img_id']; ?&gt;
         &lt;img class="avatar img-circle img-thumbnail" style="border-radius: 2px; width: 70%;" src="upload/&lt;?php echo $imagerows['img_name']; ?&gt;"&gt;
         &lt;h6&gt;Upload your product image.&lt;/h6&gt;
         &lt;input type="file" name="image" class="text-center center-block well well-sm"&gt;
         &lt;input type="text" required value="&lt;?php echo $imgid; ?&gt;" name="image_id" class="text-center center-block well well-sm"&gt;
         &lt;button type="submit" name="image" class="btn btn-success" style="margin: auto;"&gt;Update&lt;/button&gt;
         &lt;br&gt;
         &lt;br&gt;
      &lt;?php } ?&gt;
   &lt;/div&gt;
&lt;/div&gt;
&lt;?php
$id = $_POST['image_id'];
if (isset($_POST['image'])) {
    $image = $_FILES["image"]["name"];
    $image_name= addslashes($_FILES['image']['name']);
    $size = $_FILES["image"] ["size"];
    move_uploaded_file($_FILES["image"]["tmp_name"],"upload/" . $_FILES["image"]["name"]);          
    $product_img = $_FILES["image"]["name"];
    mysql_query(" UPDATE fm_product_image SET img_name = '$product_img' WHERE img_id = '$id'")or die(mysql_error());
    header('location:product.php'); 
} ?&gt;
</code></pre>