Batch updates to database?

I have a problem with batch updates
hypothetically I am a loop printing out the box and product ID

while($row = mysqli_fetch_array($data)){ 
<input type="hidden" name="cart_prod_id[]" value="<?=$row["prod_id"];?>">
<input type="hidden" name="cart_quantity[]" value="<?=$row["quan"];?>">
}

I want to modify the product information of a certain table
this is what it prints out by default:
quantity of ID/ for goods

12 / 2
13 / 1
14 / 5

when I want to change the number of one of the items, I will change 13 to 10
how to write the code received by my other party?
to update the database
I know this is the database:

foreach ... 
"UPDATE `user_cart`
        SET `quan` = {$quan}
        WHERE `prod_id` = "{$prod_id}" "

but how do I get every prod_id and quan? How to match?

prod_id = 12, quan = "2"
prod_id = 13, quan = "10"
prod_id = 14, quan = "5"

I am too weak to upload this batch. I received
more forgiveness for the first time

.
Mar.22,2021

your question doesn't seem to need an array

<?php
if(!empty($_POST)){

    foreach ($_POST as $k=>$v){
        if(strstr($k, "product_")){
            $k = substr($k, strlen("product_"));
            
            echo "update product_table set value=$v where id=$k;<br />";
        }
    }
    
    exit();
}
?>

<form method="post">
    
    <?php 
        $arr= array(
            array('id'=>1,'value'=>3),
            array('id'=>2,'value'=>4),
            array('id'=>3,'value'=>5),
        );
        
        foreach($arr as $val){
            ?>
    <label>:<?=$val['id']?></label><input type="text" value="<?=$val['value']?>" name="product_<?=$val['id']?>" /><br> 
            <?php
        }
    ?>
                   <input type="submit" />
</form>

clipboard.png

clipboard.png


INSERT INTO `user_cart` (`prod_id`, `quan`)
VALUES (12, 2),
    (13, 1),
    (14, 5)
ON DUPLICATE KEY UPDATE `quan` = VALUES(`quan`);
Menu