I have a function on my that has a delete button to erase comments. I have the button all linked up and ready to go. I just don't know what I should put on the 'delte.php' script I am creating, and what to tell it php wise to send to the db to make the status dead. as well as deleting the comment off of the page.
Thanks
Your php script would contain a query to delete the comment
mysql_query("delete from comments where id = $id");
Send a request using Ajax which won't reload the current webpage. Here is a snippet using jQuery
function deleteComment(commentId)
{
$.ajax({
type: "POST",
url: "delete.php",
data: "id="+ commentId,
success: function(msg){
alert( "Comment " + commentId + " deleted" );
}
});
}
<a href="#" onclick="deleteComment(1)">Delete Comment 1</a>
You mean something like
mysql_query("DELETE * FROM yourTable WHERE commentId = $id", $yourDbLink);
Bobby
If you do not want the browser to go anywhere you could send HTTP status 204, "No content".
Typically though you'd do a redirect to the same page with a notice saying "Comment deleted." or similar.