My question is fairly straight forward. I am creating a table from a mysql table and each row in the table holds records from the database. For each new record a new row is made and so on until there are no more records returned. I want to give them an option to delete a record and so I want to give each row it's own class name and so i am trying to echo php code into the class name.
It looks like this:
<tr class="name<?php echo $row['id'];?>">
Would the class then be name1 if $row['id'] was 1?
Alright so now that I got confirmation on this I am using jQuery to delete the record and not reload the page.
What i am trying to do is when a user clicks a button I use AJAX to delete a record in the db and on the screen. I have it working to delete from the db, but I am having trouble deleting it on the screen without re-loading the page.
Here is my jQuery code:
$(".delete").click(function(){
var delete_id = "delete_id="+$(this).attr("id")
$.ajax({
type: "POST",
dataType: "HTML",
url: "deleteScript.php",
data: delete_id,
success: function(data) {
$(".name"+$(this).attr("id")).remove();
}
});
});
Shouldn't this remove anything with the class name on the screen? I have used alert to make sure that .name"+$(this).attr("id") was right, and it returned what I thought it would. So I am now confused where I went wrong.
Help?