是的,这是可能的,但你应该只发送条目的id到一个特定的页面来删除entry.never整个sql语句。
<button id="<?php echo $row['id']; ?>" class="delbutton"></button>
这个脚本添加到您的网页
<script type="text/javascript" >
$(function() {
$(".delbutton").click(function() {
var del_id = $(this).attr("id");
var info = 'id=' + del_id;
if (confirm("Sure you want to delete this post? This cannot be undone later.")) {
$.ajax({
type : "POST",
url : "delete_entry.php", //URL to the delete php script
data : info,
success : function() {
}
});
$(this).parents(".record").animate("fast").animate({
opacity : "hide"
}, "slow");
}
return false;
});
});
</script>
最后,但没有起码你的删除脚本
<?php
include 'connection.php';
$id=$_POST['id'];
$delete = "DELETE FROM table WHERE id=$id";
$result = mysql_query($delete) or die(mysql_error());
?>
是。你需要搜索ajax。 – jeroen 2014-10-20 14:29:32
你不应该“发送一个sql语句”。 YOu可以向服务器发送一条指令,告诉它删除一条特定的记录,但是你的客户端应用程序不应该在sql级别处理任何事情。考虑有人搞清楚你的“run sql”查询语法,并通过http://example.com/dosql.php?sql=drop数据库databasename()'“oops”发送。 – 2014-10-20 14:36:27
“发送一条sql语句”我认为它是不言而喻的,一个sql查询将是PDO或mysqli。 – 2014-10-20 14:47:30