我建議使用Ajax 「刪除=(ID)?」。在這裏,我將使用jQuery使用
$(function() {
$(".wh").on("click",function(e) {
e.preventDefault(); // cancel the click
$.get(this.href,function(data) { // does the student still exist?
if (confirm("delete" +data+"?")) {
$.get("otherphp.php?st_id="+$(this).data("id"),function(data) {
$(this).next().html(data); // show response
});
}
});
});
});
做
<a class="wh" data-id="<?=$rows['student_id']?>" href="edit-mark.php?st_id=<?=$rows['student_id']?>" title="Edit">Edit Marks</a><span class="confirmation"></span>
或者隱藏從蜘蛛
在href
<a class="wh" href="onlyworkswithjavascript.html"
data-id="<?=$rows['student_id']?>" data-href="edit-mark.php?st_id=<?=$rows['student_id']?>"
title="Delete">Delete Marks</a><span class="confirmation"></span>
$(function() {
$(".wh").on("click",function(e) {
e.preventDefault(); // cancel the click
if (confirm("delete" +data+"?")) {
$.get($(this).data("href"),function(data) {
$(this).next().html(data); // show response
});
}
});
});
1:從來沒有一個調用刪除鏈接 - 從一個訪問Google蜘蛛和你的數據庫是空的。 2.使用方法Ajax請求:「DELETE」並顯示返回消息 – mplungjan
請不要再使用'mysql_ *'函數。它們在PHP5中被棄用,並在PHP7中被刪除。使用MySQLi或PDO準備語句來防止mysql注入。 – Jer
@mplungjan如果刪除身份驗證部分後面,則沒有任何問題。 – tilz0R