Gostaria de saber como posso fazer para que ao clicar no botao de deletar o registro na tabela e no banco de dados apague? Obrigada!
*deletePagamentos.php
<?php
// sql to delete a record
$id_pag = $_GET["id"];
$query = "DELETE FROM ll_pagamento WHERE id= $id_pag";
//query execution
$result = mysqli_query($connect,$query);
header('Location:tablePagamentos.php');
}
$conn->close();
?>
*tablePagamentos.php
<body>
<div class="container">
<h2>Lista de Pagamentos</h2>
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>Nome</th>
<th>Data pagamento</th>
<th>Valor</th>
</tr>
</thead>
<tbody>
<?php
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
?>
<tr>
<td><?php echo $row["id"] ?></td>
<td><?php echo $row["nome"] ?></td>
<td><?php echo $row["data"] ?>"</td>
<td><?php echo $row["valorpago"] ?>"</td>
<td><a href="#" href="edit.php" class="btn btn-primary btn-xs"><span class="fa fa-edit"></span></a></td>
<td><a href="deletePagamento.php?id_pag=<?php echo $row['id'];?>">Deletar</a></td>
</tr>
<?php
}
}
?>
</tbody>
</table>
<a href="index.php" class="btn btn-primary btn-xs">Voltar</a>
</div>
</body>