0
Aquivo php.
<?php
include "mysqlexecuta.php"; // Executa a cláusula SQL
$servidor='localhost';
$banco='xerox';
$usuario='root';
$senha='';
$conexao = mysqli_connect($servidor,$usuario,$senha);
mysqli_select_db($conexao, $banco);
$sql = "SELECT id, id_usuario, data_req, tipo, quant, anexo, assunto, dataentrega, status FROM requisicao ORDER BY id ASC";
$result = mysqli_query($conexao,$sql) or trigger_error(mysqli_error($conexao));
echo "<table border='1'>
<tr>
<th>Número</th>
<th>Requerente</th>
<th>Data do Requerimento</th>
<th>Tipo</th>
<th>Quantidade</th>
<th>Anexo</th>
<th>Assunto</th>
<th>Data de Entrega</th>
<th>Status</th>
<th>Aprovar </th>
</tr>";
while ($status = 'pendente') {
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<th>" . $row['id'] . "</td>";
echo "<th>" . $row['id_usuario'] . "</td>";
echo "<th>" . $row['data_req'] . "</td>";
echo "<th>" . $row['tipo'] . "</td>";
echo "<th>" . $row['quant'] . "</td>";
echo "<th>" . $row['anexo'] . "</td>";
echo "<th>" . $row['assunto'] . "</td>";
echo "<th>" . $row['dataentrega'] . "</td>";
echo "<th>" . $row['status'] . "</td>";
echo "<th> <form method='POST' action='aprovar.php'>
<input type='hidden' name='id' value='id'>
<input type='submit' name='aprova' value='sim'>
</form>
</td>";
echo "</tr>";
}
echo "</table>";
}
?>
Filing cabinet approve.php
<?php
$servidor='localhost';
$banco='xerox';
$usuario='root';
$senha='';
$conexao = mysqli_connect($servidor,$usuario,$senha);
mysqli_select_db($conexao, $banco);
if(isset($_POST["aprova"])) {
$sql = "UPDATE requisicao SET status='aprovado' WHERE id='".$_POST["id"]."'";
$query = mysqli_query($conexao, $sql);
if($query) {
echo "Sucesso!";
}
else {
echo "Falha!";
}
}
?>
The problem is here
<input type='hidden' name='id' value='id'>
<- the value is asid
when it was supposed to be$row['id']
– NoobSaibot
Could you tell me how to put it? the way I put it gave error in the syntax:c
– thaina
Look at the answer I put.
– NoobSaibot
worked perfectly, thank you @Noobsaibot for real! <3
– thaina