0
I have a page that receives the ID(s) of the product(s) that are already saved in the 'products' table and that are being added via $_POST
in an array that receives this data(product name, product name, product value,quant_product)
In the 'products' table these data are already saved, such as id_product, product name, etc, and also other data such as ipi, icms, Cofins.
I’m getting via $_POST
just some fields like the ID
(s) of the Product(s) added(s), I also need to consult the REST of the data LINKED to this(s) ID(s), which are already saved(s) in the table 'products' (ex: ipi,icms,Cofins).
SUMMARIZING: Also pick the other fields of the products table linked to each ID
added via $_POST
arrays (e.g.: id_product[] )
//POST em array que recebo
$valor_unitario = $_POST['valorunitario'];
$nome-produto= $_POST['nome_produto'];
$quant_produto = $_POST['quant_produto'];
$subtotal = $_POST['subtotal'];
$id_produto = $_POST['id_produto'];
//AQUI INSERE OS ARRAYS NO BANCO DE DADOS, RECEBE OS PRODUTOS ADICIONADOS VIA POST (AQUI QUERO SALVAR O RESTANTE DOS CAMPOS DO PRODUTO ATRAVÉS DO ID DELES.
$i=0;
$sql= "INSERT INTO `log_nfe_produtos` (`NOME_PRODUTO`, `VALOR_UNITARIO`, `QUANT_PRODUTO`, `SUBTOTAL`, `ID_EMPRESA`,`ID_NF`) VALUES ";
foreach($nome_produto as $p){
$sql=$sql."('$p','$valor_unitario[$i]','$quant_produto[$i]','$subtotal[$i]','1','$cod_pedido[$i]'),";
$i++;
}
$sqlFinal = substr($sql, 0, strlen($sql)-1);
$sqlFinal2 = $conn->prepare("$sqlFinal");
$sqlFinal2->execute();
Okay, I will comment: your question does not make much sense. It has like [Edit] and try to be clearer in your text?
– Woss
Okay, I changed the question, check if you have conditions to solve.
– Alh