0
<?php
$sql = mysql_query ("SELECT * FROM cadastro ");
while($resultado = mysql_fetch_array($sql)){
$idrepete = $resultado['id'];
?>
#divId<echo idrepete; ?>{
width:100%;
}
<?php
}
?>
This is the part that works, now is the part that I want to do:
<?php
if(isset($_POST['encerrar'])){
$idpedidos1 = $pedido + 1;
$contamais1 = mysql_query ("INSERT INTO idpedido (idpedido) VALUES ($idpedidos1) "); // até aqui tudo beleza
$pedidosestoque = mysql_query("SELECT * FROM pedidos WHERE productid = $pedido");
while($pedidosresultestoque = mysql_fetch_array($pedidosestoque)){
$productidestoque = $pedidosresultestoque['productid'];
$nomeestoque = $pedidosresultestoque['nome'];
$pedidos2estoque = mysql_query("SELECT * FROM produtos WHERE id = $nome");
while($pedidosresult2estoque = mysql_fetch_array($pedidos2estoque)){
$nome2estoque = $pedidosresult2['nome'];
$preco2estoque = $pedidosresult2['preco'];
$estoqueid = $pedidosresult2estoque['id'];
$estoquedisponivel2 = $pedidosresult2estoque['estoque'];
?>
<?php
// Aqui é o que quero fazer, como no exemplo de css a #divId sempre recebe o id para ficar tipo #divId1, #divId2 etc, quero fazer o mesmo na variavel sql ali em baixo EXE
$sql = mysql_query ("UPDATE produtos SET estoque = '$estoquedisponivelmenos' WHERE id=$estoqueid ");
}
}
header("location:index.php");
}
Whenever the while
assign a different value to my $sql
so the stock balance error doesn’t happen. What happens is that only the last product posted that receives the stock balance I think it is because the last loop of $sql
which counts in the case if the id
ends in 3 only the product of id
3 will receive the stock balance.
I tried to improve but mainly the last paragraph is an incomprehensible text. I didn’t even get the title better because you can’t tell the real problem. See if you can make the problem easier to understand. Score. Write the text carefully. Think that those who can help you do not know what it is. Give all the details clearly. Don’t leave room for confusion. If you work hard on the text, who knows until you better understand the problem and can solve it yourself.
– Maniero
Again: dabble in the text, who knows until you better understand the problem and manage to solve alone.
– bfavaretto