0
I’m with a function, trying to delete a row from my sql table, but nothing has happened.
HTML
:
<span class="action"><a href="#" id="<?php echo $id; ?>" class="delete" title="Delete">Sim</a></span>
<script src="js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$('.delete').click(function()
{
if (confirm("Tem certeza que deseja excluir?"))
{
var id = $(this).parent().parent().attr('id');
var data = 'id=' + id ;
var parent = $(this).parent().parent();
$.ajax(
{
type: "POST",
url: "deletar-aguardando.php",
data: data,
cache: false,
success: function()
{
parent.fadeOut('slow', function() {$(this).remove();});
}
});
}
});
$('table#delTable tr:odd').css('background',' #FFFFFF');
});
</script>
In the archive deletar-aguardando.php
I have:
include_once('conexao.php');
if($_POST['id'])
{
$id=($_POST['id']);
$delete = "DELETE FROM clientes WHERE id='$id'";
mysqli_query($con, $delete);
}
My file conexao.php
is working.
did not work, continued to do nothing in the document
– Wendell
at the beginning of your HTML, what is the value of $id ?
– Allan Andrade
when you made this comment you made me find the error, rsrs. At the beginning of html was
<?php $id = $dados['idclientes']; ?>
whereidclientes
is the table column name and in the filedeletar-aguardando.php
I put the name of the column just likeid
and the right one wasidclientes
. However thank you, rsrs– Wendell
Any questions, just send direct msg or a comment here.
– Allan Andrade