【发布时间】:2012-06-19 23:44:18
【问题描述】:
我正在建立一个我之前提出并解决的问题:front end mysql, deleting a row
基本上,我有一个前端,用户可以在其中查看数据库。我不想在每一行旁边都有一个删除按钮,而是有一个可以为多行选择的复选框。然后,用户只需单击一个删除按钮,所有选定的行都会被删除。我对php和mysql不太了解,所以我不知道如何处理我已经拥有的代码。
目前,onclick 调用了一个删除函数。有人可以帮忙吗?
我有一个将mysql数据的html输出成long strong的php文件,我需要更改的部分是:
$display_string .= "<td class='blank'><input type=\"button\" VALUE=\"Delete\" onclick='delFunction(" . $row['ID'] . ")' ></td>";
接下来我的删除功能:
function delFunction(ID){
// confirm delete
if (!confirm(\"Are you sure you want to delete?\")) return false;
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject(\"Msxml2.XMLHTTP\");
} catch (e) {
try{
ajaxRequest = new ActiveXObject(\"Microsoft.XMLHTTP\");
} catch (e){
// Something went wrong
alert(\"Your browser broke!\");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('ajaxDiv');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
var queryString = \"?ID=\" + ID
ajaxRequest.open(\"GET\", \"delete_row.php\" + queryString, true);
ajaxRequest.send(null);
}
【问题讨论】:
标签: php mysql onclick delete-row