1
I’m trying to use PHP with Sweet Alert already tried with FIXED ID and it works. I’m trying to do that:
while ($row = mysqli_fetch_assoc($sql)) {
echo '<tr>';
echo '<td>' . $row['id_apoio'] . '</td>';
echo '<td>' . $row['nome_apoio'] . '</td>';
echo '<td>' . $row['email_apoio'] . '</td>';
echo '<td>' . $row['tel_apoio'] . '</td>';
echo '<td>' . $row['cel_apoio'] . '</td>';
echo '<td>' . $row['cargo_apoio'] . '</td>';
echo '<td>' . $row['especialidade_apoio'] . '</td>';
echo '<td>' . $row['conselho_apoio'] . '</td>';
echo '<td><button class="bg-transparent border-0 d-block mx-auto" onclick="location.href=\'cadastro-completo-apoio.php?cadastro='. $row['id_apoio'] .'\'"><i class="fa fa-search"></i><br></td>';
echo '<td><button class="bg-transparent border-0 d-block mx-auto" onclick="location.href=\'editar-apoio.php?edita='. $row['id_apoio'] .'\'"><i class="fa fa-edit"></i><br></td>';
echo '<td><button class="bg-transparent border-0 d-block mx-auto sweet-alert" id="'.$row['id_apoio'].'"><i class="fa fa-user-times"></i><br></button>';
}
?>
JS:
document.getElementById('<?php $row['id_apoio']?>').onclick = function(){
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "info",
showCancelButton: true,
confirmButtonClass: 'btn-primary',
confirmButtonText: 'Primary!'
});
};
the button will serve to confirm the item deletion
Thanks again, Sam! You’re a beast!
– João Vitor
anyway, I can’t pass the user id to delete.
– João Vitor
echo '<td><button class="bg-transparent border-0 d-block mx-auto deletar" onclick="location.href=\'deleta-apoio.php?deleta='. $row['id_apoio'] .'\'">
js is what you gave me...– João Vitor
I updated the answer. Keep the id on each button:
id="'.$row['id_apoio'].'
and remove that onclick you put on.– Sam
Thanks, it worked out and I could understand how this integration works. If I could give you a hug. Sam is a Beast
– João Vitor