Puder hacer unas modificaciones al codigo pero no logro arreglarlo bien aqui les muestro
Código PHP:
<?php
$res = "";
$str = "";
$resta = array_filter($resta);
foreach($resta as $valorr) {
foreach($id as $valor)
$str .= "UPDATE `inventario`.`registro` SET `unidades_r` = `unidades_r` - $valorr WHERE ID_R = $valor;</br>";
}
$idd = $str;
echo "$idd";
Resultado que muestra
Código PHP:
UPDATE `inventario`.`registro` SET `unidades_r` = `unidades_r` - 4 WHERE ID_R = 1;
UPDATE `inventario`.`registro` SET `unidades_r` = `unidades_r` - 4 WHERE ID_R = 6;
UPDATE `inventario`.`registro` SET `unidades_r` = `unidades_r` - 11 WHERE ID_R = 1;
UPDATE `inventario`.`registro` SET `unidades_r` = `unidades_r` - 11 WHERE ID_R = 6;
el resultado que busco seria
Código PHP:
UPDATE `inventario`.`registro` SET `unidades_r` = `unidades_r` - 4 WHERE ID_R = 1;
UPDATE `inventario`.`registro` SET `unidades_r` = `unidades_r` - 11 WHERE ID_R = 6;
se parece mucho a lo que quiero pero tengo problema con el foreach de restar si trato de unirlo se duplica y salen 4 registro en vez de dos , creo que la solucion esta en unir esos dos foreach algo como foreach($resta as $valorr , $id as $valor) seguire buscando si hay algo parecido