如何使用一个按钮更新所有输入字段并按下按钮以单独删除项目?

I've been making a shopping cart where I display the products with a delete button for each product and an update button to update all the quantity fields. The problem is that when I have managed to make update button work the delete button delete the last product not the one that I wanted to. I know is a problem with the form but i do not know how to resolve it.

   $i = 0;
 while($row = $result->fetch_assoc()){  
   //loop product info 

   echo'<form action="" method="POST">
        <input class="inp" type="hidden" name="h_order" value="'.$row['order_id'].'"/>
        <input class="inp" type="hidden" name="order[]" value="'.$row['order_id'].'"/>
        <input class="inp" style="width:30px;" type="text" name="';
        echo 'quantity[$row['order_id']]'; 
        echo 'value="'.$row['quantity'].'" autocomplete="off"/>';
if($i == 0){
echo'<table>';
}
   echo '<td>'.$total.'</td>    
    <td>
        <center>        
            <button class="action red" type="submit" name="delete" title="Delete">
                <i class="fa fa-trash-o fa-2x"></i>
            </button>
        </center>
    </td>   
    </tr>';
    $i++;
}
 echo '<tr>
    <td colspan="6">
        <button class="button action blue" style="float:right;" type="submit" name="update" title="Update quantity">
            <i class="fa fa-refresh fa-lg"></i>
                <a>Update cart</a>
        </button>
    </td>
 </tr>  
</table>
</form>';