My question is how can I update several records of a Mysql table from php?
In the variable $ conver2 the values that I want to insert are saved
I put the update inside the foreach so that the sentence would be repeated according to the amount of data found in $ conver2.
If I update the records but it gives me the last value of the $ conver2 For example if in the $ conver2 there were these data:
'6,500.00' // '8,100.00', // '11,100.00'.
I would be updating the records but putting in all the last value of bone '11, 100.00 '.
<?php
$conexion = mysqli_connect('localhost', 'root', '', 'scabc');
$query = mysqli_query($conexion, "SELECT valStockI FROM movimientos where idMovimiento >= " . $idMovimiento . " and idStockI= " . $idStockI . "");
$stockvalorplus = 0;
$stockvalorplus = $valornuevo - $valorantiguo;
foreach ($query as $dato) {
$a = $dato['valStockI'];
$conver = str_replace(",", "", $a);
$total = $conver + $stockvalorplus;
$conver2 = number_format($total, 2, '.', ',');
echo $conver2;
echo '</br>';
mysqli_query($conexion, 'UPDATE movimientos set valStockI=" ' . $conver2 . ' " where idMovimiento >=' . $idMovimiento . ' and idStockI= ' . $idStockI . ' ');
}
?>