I have a jquery delete statement and it’s only deleting the NEWEST upload on my files (using mysql) Say I had “file uploaded first”, “file uploaded second”, “file uploaded last(newest file)”. If I click “file uploaded first or second”, it deletes the newest (file uploaded third).
$(document).on('click', '.del', function(){
var sid = $(this).next('.hiddenVid').val();
$.ajax({
type: "GET",
url: "delete.php",
data: {id:sid}
});
return false;
});
this is your error ->
It will only produce the ID for the latest item that you put in.
Add an item to your echo statement so you can reference it later in the click function.
Add a reference to the vid in a hidden input.
Change this
To this:
Change your click function to reference the real sid now.
If you want to return the rows after the update, you’ll need to spit the data back to be printed, based on the above method you use to retrieve the rows and return them, you could reuse it.
Now we need to change the click handler to expect a dataType and replace the existing data in the table.