我是一个新手与PHP和我试图使用jquery网格,与表单编辑和删除。 我正在实施编辑,它出现了 - 错误状态:'错误'。错误代码:0,当我按下提交按钮时,错误发生但是进行了更改... 我的网格......
<script>
var lastsel;
$(function() {
$("#toolbar").jqGrid({
mtype: 'POST',
editurl: 'http://www.onetag.pt/eulen/edit.php',
caption:"Tags",
colNames:['TagID','Nome', 'Descricao', 'Tipo'],
colModel:[
{name:'tagID',index:'tagID',hidden:true},
{name:'name',index:'name',editable:true},
{name:'description',index:'description',editable:true},
{name:'type',index:'type'}
],
datatype:"json",
height:421,
rownumWidth:40,
pager:'#ptoolbar',
rowList:[10,20,30],
rowNum:10,
sortname:'tagID',
sortorder:'desc',
url:'/tags/list/',
viewrecords:true,
width:740
});
$("#toolbar").jqGrid('navGrid','#ptoolbar',{del:true,add:false,edit:true,search:true});
$("#toolbar").jqGrid('filterToolbar',{stringResult:true,searchOnEnter:false});
});
</script>
和editurl.php
<?php
// connect to the database
$dbhost = "localhost";
$dbuser = "blah";
$dbpassword = "blah";
$database = "blah";
$tablename = "tags";
$db = mysql_connect($dbhost, $dbuser, $dbpassword)
or die("Connection Error: " . mysql_error());
mysql_select_db($database) or die("Error conecting to db.");
//mysql_set_charset('utf8',$database);
mysql_query("SET NAMES 'utf8'");
if($_POST['oper']=='add')
{
}
if($_POST['oper']=='edit')
{
$id = mysql_real_escape_string($_POST['id']);
$name = mysql_real_escape_string($_POST['name']);
$description = mysql_real_escape_string($_POST['description']);
$sql = "UPDATE ".$tablename." SET name ='".$name."', description ='".$description."' WHERE tagID = ".$id;
$result=mysql_query($sql) or die(mysql_error());
mysql_close($db);
}
if($_POST['oper']=='del')
{
}
?>
我选择第一行,然后按编辑按钮 然后它出现在编辑表格中...... 然后我做了所需的改变...... 然后按提交按钮,出现错误...
我关闭编辑表单,然后按f5刷新,数据字段已更改......