我在做一个积垢项目。我所有的其他功能都在工作,除了更新。我已经包含了一个catch来查看sql语句中是否有任何错误,但它没有捕获任何内容。当我按save changes时,代码会被执行,但不会反映表中的任何更改。我已经检查了所有的错误日志也没有明显的。有什么想法吗(我不得不删除字段中的详细信息,因为它们包含可识别的信息)。
function edit(rowID) {
$.ajax({
url: 'ajax.php',
method: 'POST',
dataType: 'json',
data: {
key: 'getRowData',
rowID: rowID
}, success: function (response) {
$("#editRowID").val(response.rowID);
$("#fullName").val(response.fullName);
$("#dob").val(response.dob);
$("#ethnicity").val(response.ethnicity);
$("#gender").val(response.gender);
$("#nhsNo").val(response.nhsNo);
$("#hospNo").val(response.hospNo);
$("#idMarks").val(response.idMarks);
$("#address").val(response.address);
$("#tableManager").modal('show');
$("#manageBtn").attr('value', 'Save Changes').attr('onclick', "manageData('updateRow')");
}
});
}
function manageData(key) {
var fullName = $("#fullName");
var dob = $("#dob");
var ethnicity = $("#ethnicity");
var gender = $("#gender");
var nhsNo = $("#nhsNo");
var hospNo = $("#hospNo");
var idMarks = $("#idMarks");
var address = $("#address");
var editRowID = $("#editRowID");
if (isNotEmpty(fullName) && isNotEmpty(dob) && isNotEmpty(ethnicity) && isNotEmpty(gender) && isNotEmpty(nhsNo) && isNotEmpty(hospNo) && isNotEmpty(idMarks) && isNotEmpty(address)){
$.ajax({
url: 'ajax.php',
method: 'POST',
dataType: 'text',
data: {
key: key,
fullName: fullName.val(),
dob: dob.val(),
ethnicity: ethnicity.val(),
gender: gender.val(),
nhsNo: nhsNo.val(),
hospNo: hospNo.val(),
idMarks: idMarks.val(),
address: address.val(),
rowID: editRowID.val()
}, success: function (response) {
alert(response);
}
});
}
}
$fullName = $conn->real_escape_string($_POST['fullName']);
$dob = $conn->real_escape_string($_POST['dob']);
$ethnicity = $conn->real_escape_string($_POST['ethnicity']);
$gender = $conn->real_escape_string($_POST['gender']);
$nhsNo = $conn->real_escape_string($_POST['nhsNo']);
$hospNo = $conn->real_escape_string($_POST['hospNo']);
$idMarks = $conn->real_escape_string($_POST['idMarks']);
$address = $conn->real_escape_string($_POST['address']);
$rowID = $conn->real_escape_string($_POST['rowID']);
if ($_POST['key'] == 'updateRow') {
$conn->query("UPDATE suspects SET fullName='$fullName', dob='$dob', ethnicity='$ethnicity', gender='$gender', nhsNo='$nhsNo', hospNo='$hospNo', idMarks='$idMarks', address='$address' WHERE id= '$rowID'");
exit('Record for '.$fullName.' updated.');
}
暂无答案!
目前还没有任何答案,快来回答吧!