i am implementing clothing shopping website in which admin manages stock for example add, update, delete stock. i am having problem with my delete query. stock is displayed in table and every row has its own delete button. when i click on delete button it always takes last row id and delete that and not that row which i want. Query is taking always last row id. CODE:
  <form action="" method="post" enctype="multipart/form-data" name="deleting" >
            <table align="center" border="0" id="myTable" class="table table-striped table-bordered table-list">
    <tr>
      <th>Product Code</th>
      <th>Brand</th>
      <th>Price</th>
      <th>Gender</th>
      <th>Category</th>
      <th>Material</th>
      <th>Size</th>
      <th>Description</th>
      <th>Quantity</th>
      <th>Delete Stock</th>
      </tr> 
<?php
$sql = "SELECT * FROM add_stock  ORDER BY id DESC"; 
                $rs_result = mysqli_query ($sql);
                   while ($result=mysqli_fetch_array($rs_result) )
            {
              ?>
              <tr>
                <td><?php echo $result['id'];?></td>
                <td><?php echo $result['brand_name'];?></td>
                <td><?php echo $result['price'];?></td>
                <td><?php echo $result['gender_name'];?></td>
                <td><?php echo $result['category_name'];?></td>
                <td><?php echo $result['material_name'];?></td>
                <td><?php echo $result['size_name']; ?></td>
                <td><?php echo $result['dress_description'];?></td>
                <td><?php echo $result['dress_quantity'];?></td>
               <td><input type="hidden" name="ID" value="<?php echo $result['id']; ?>"><input type="submit" name="delete" value="Delete" ></td>
              </tr>
              <?php
            }      
            ?>
</table>
</form>
  <?php 
if (isset($_POST['delete'])) {
$id=$_POST['ID']; //problem is here: it always takes last row id     
$link=mysqli_connect("localhost","root","") or die("Cannot Connect to the database!");
mysqli_select_db("login",$link) or die ("Cannot select the database!");
$query="DELETE FROM add_stock WHERE id='".$id."'";
$result=mysqli_query($query,$link) or die(mysqli_error($link));
if($result)
{ 
 echo '<script>confirm("Are you sure want to delete this record?")</script>';
 echo '<script>alert("Record ".$id." removed successfully!")</script>';
}
else
{
  die ("An unexpected error occured while <b>deleting</b> the record, Please try again!");
              }
              }
?>
 
     
    