Good evening, guys! I'm having a GIANT difficulty to delete a DB line from PHP, I figured the following by the code below: $ line would get the array with all the BD records, and from it delete the ID I wanted, how it's in of a while I would be able to delete only that ID. But the problem is that it deletes all the rows from the database, can anyone point me the error? I guess it's with the while, but I can not. If you have any other way to delete it would also appreciate if you commented, the code follows below:
<div class="row panel" style="margin-top:1%;">
<div class="medium-12 columns">
<table>
<h1>Jogos Cadastrados</h1>
<tr>
<td>ID</td>
<td>Nome</td>
<td>Descrição</td>
<td>Preço</td>
<td>Excluir</td>
</tr>
<?php
require("connect.php");
$sql = "select * from tblgames";
$qry = mysqli_query($con,$sql);
while($linha = mysqli_fetch_array($qry)){
?>
<tr>
<td><?php echo $linha["id_game"]?></td>
<td><?php echo $linha["nome_game"]?></td>
<td><?php echo $linha["desc_game"]?></td>
<td><?php echo "R$".$linha["preco_game"]?></td>
<td><form method="post"><button type="submit"><input type="hidden" name="excluir">✕</button></form>
<?php
if(isset($_POST['excluir'])){
$id = $linha["id_game"];
$sql2 = "delete from tblgames where id_game='$id'";
$qry2 = mysqli_query($con,$sql2);
}
?>
</td>
</tr>
<?php } ?>
</table>
</div>
</div>