1
I have a question, how do I add the entered value of the form to the data that is recorded inside the database? The structure is more or less this.
In the form action it takes me to the alterphp page.
$p = new Produto();
$id = addslashes($_POST['id']);
$nome = addslashes($_POST['nome']);
$quantidade = addslashes($_POST['quantidade']);
$descricao = addslashes($_POST['descricao']);
$p->alterarProduto($id, $nome, $quantidade, $descricao);
The function alterProduct is within Product.class.php and belongs to the Product() object, i search from the database the amount of products by the associated id in the page itself alters.php
global $pdo;
$sql = "SELECT * FROM produtos WHERE id = '$id'";
$sql = $pdo->prepare($sql);
$stmt = $sql->execute();
foreach ($sql as $row){
$row['nome'];
$row['quantidade'];
$row['descricao'];
}
The syntax would look something like this: $quantity = $quantity + $valueAtual, the problem that I’m not getting the values correctly and do the sum.
What values you’re not getting right?
– Woss
If one of the answers is correct, I suggest you mark it as "accepted" so that your question can help other users as well
– Julyano Felipe