dimanche 26 juin 2016

Record not deleted from database

I am using following code to show MySQL records on a web site table. This is the column whith the delete button: <td align="center"><a id="<?php echo $row['id_peticion']; ?>" class="delete-link" href="#" title="Delete"> <img src="delete.png" width="20px" /> </a></td> This is the JS code called when user clicks on the delete button: /* Data Delete Starts Here */ $(".delete-link").click(function() { var id = $(this).attr("id"); var del_id = id; var parent = $(this).parent("td").parent("tr"); if(confirm('Seguro que quieres borrar la petición # = ' +del_id)) { $.post('delete.php', {'del_id':del_id}, function(data) { parent.fadeOut('slow'); }); } return false; }); /* Data Delete Ends Here */ And this is the code from delete.php <?php include_once 'dbconfig.php'; if($_POST['id_peticion']) { $id = $_POST['id_peticion']; $stmt=$db_con->prepare("DELETE FROM tbpeticiones WHERE id_peticion=:id"); $stmt->execute(array(':id'=>$id)); } ?> When clicked, the record dissapears from the table but is not deleted from the database. I cannot find the reason why... Thank you

Aucun commentaire:

Enregistrer un commentaire