Hello, I would like to make a sweetalert to delete the records from my website, but I do not know how to do it since I do not understand javascript ... Can anyone give me a light ?
My class / crud.php page where the querys are (the part of delete):
public function excluirAluno($idAluno){
global $pdo;
$sql = $pdo->prepare("DELETE FROM alunos WHERE id_alunos = '$idAluno'");
$sql->execute();
}
public function excluirPagamentos($idAluno){
global $pdo;
$sql = $pdo->prepare("DELETE FROM pagamentos WHERE alunos_id = '$idAluno'");
$sql->execute();
}
And here comes the home.php where they show the records (just the php code):
<?php
include_once 'config.php';
global $pdo;
$sql = "select * from alunos left join pagamentos on id_alunos =
pagamentos.alunos_id order by nome";
$sql = $pdo->query($sql);
if ($sql->rowCount() > 0)
{
foreach ($sql->fetchAll() as $aluno):
?>
<tr>
<td> <?php echo $aluno['nome']; ?> </td>
<td> <?php echo $aluno['fone']; ?> </td>
<td> <?php echo $aluno['email']; ?> </td>
<td> <?php echo $aluno['situacao_aluno']; ?>
</td>
<?php
echo "<td><a href='editar.php?id_alunos=" . $aluno['id_alunos'] . "'
class='btn btn-dark' role='button'>Editar</a></td>";
echo "<td><a href='delete_submit.php?id_alunos=" . $aluno['id_alunos'] . "'
class='btn btn-danger'>Deletar</a></td>";
echo "</tr>";
?>
</tr>
<?php
endforeach;
}
?>