1
I have the following question: I have a condition if
else
in php
the problem is that I need a value inserted into a field in the database table for the script
fulfil the condition of if
or of else
.
My question is how can I take this value from the bank and move to the variable that will be used in the condition of if
else
. Below my code, in this case I need the variable "click" to receive the value of the table field of the database.
$clique=?????????
if($clique == 1){
echo ("<script>alert('ATENÇÃO: Esse registro já foi constado como entregue e não poderá ser inserido novamente!'); location.href = '../../emprestimo.php';</script>");
}
else
{
$query = $conexao->prepare("INSERT INTO memprestimo (idemprestimo, movimento, iditem, nomealuno, email, quantidade) SELECT idemprestimo, 'Emprestimo', iditem, nomealuno, email, quantidade FROM emprestimo WHERE idemprestimo = :idemprestimo");
$query->bindParam(':idemprestimo', $idemprestimo, PDO::PARAM_INT);
$res = $query->execute();
unset($query);
$query2 = $conexao->prepare("UPDATE emprestimo SET clique=1 WHERE idemprestimo = :idemprestimo");
$query2->bindParam(':idemprestimo', $idemprestimo, PDO::PARAM_INT);
$res2 = $query2->execute();
unset($query2);
echo ("<script>alert('Entrega constada com sucesso!'); location.href = '../../emprestimo.php';</script>");
}
Take the amount in the bank and put it in the $click, like:
$clique = row['coluna'];
.– Sam