0

我是 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 刷新,数据字段已更改...

4

0 回答 0