1
I have the following function to delete a record:
//FUNÇÃO PARA LISTAR TODOS OS USUAROS
public function ListarUsuarios()
{
$stmt = $this->conn->prepare ("SELECT *FROM N00_Usuario");
$stmt->execute();
while($lista= $stmt->fetch(PDO::FETCH_ASSOC)){
echo"<tr>";
echo "<td><input type='checkbox' name='checkbox[{$lista->id}]'/></td>";
echo" <td>{$lista['NomeUsuario']}</td>";
echo" <td>{$lista['EmailUsuario']}</td>";
echo"</tr>";
} ;
}
//FUNÇÃO PARA APAGAR
public function Apagar()
{
$stmt = $this->conn->prepare("DELETE FROM N00_Usuario WHERE idUsuario = :id");
$stmt->bindParam(':id', $id);
$stmt->execute();
}
And in the other Home.php file I have the following code:
<section class='statis text-center'>
<table class="table table-hover">
<thead>
<tr>
<th>#</th>
<th>Usuario</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $auth_user->ListarUsuarios();?></td>
</tr>
</tbody>
</table>
<a href="delete.php?id=<?php echo $auth_user->Apagar();?>" onclick="return confirm('Tem certeza de que deseja remover?');">Remover</a>
<button type='submit' class='btn btn-primary' name='id'>Adicionar</button>
<button type='submit' class='btn btn-info' name='id'>Editar</button>
<div>
</div>
</section>
Does anyone know how to get out of this? I can’t pass an id to be able to delete a selected item.
put the complete error line!
– Juven_v
I believe we’re missing the
id
product as parameter in function– Vinicius Shiguemori
@Viniciusshiguemori if this is the case how do I pass this "ID" in my function please?
– Gladiador