我在删除行时遇到问题,我认为是因为没有发送帖子[id]。将显示删除消息,但不会删除该行。这是我的代码:
JAVASCRIPT:
$(document).ready(function () {
$('#PersonTableContainer').jtable({
title: 'Tabla de Clientes',
paging: true,
pageSize: 10,
sorting: true,
defaultSorting: 'Nombre ASC',
actions: {
listAction: 'AccionesClientes.php?action=list',
createAction: 'AccionesClientes.php?action=create',
updateAction: 'AccionesClientes.php?action=update',
deleteAction: 'AccionesClientes.php?action=delete',
},
fields: {
id: {
key: true,
create: false,
edit: false,
list: false
},
PHP:
else if($GET["action"] == "delete")
{
//Delete from database
$result = mysqlquery("DELETE FROM clientes WHERE id= ".$_POST["id"].";");
//Return result to jTable
$jTableResult = array();
$jTableResult['Result'] = "OK";
print json_encode($jTableResult);
}
任何人都可以看到错误的位置吗?
答案 0 :(得分:0)
抱歉,我没有给LIST方法中的id字段赋值
$result = mysql_query("SELECT **id as id**, nombre as Nombre, apellido1 as Apellido1, cedula as Cedula, empresa as Empresa, nit as Nit FROM clientes ORDER BY " . $_GET["jtSorting"] . " LIMIT " . $_GET["jtStartIndex"] . "," . $_GET["jtPageSize"] . ";");
这解决了这个问题。