遇到jEditable问题

时间:2011-06-19 12:54:50

标签: php jquery mysql jeditable

jeditable的问题。想要动态更改用户信息但它不起作用:在调试期间它显示POST以更改.php确定,没有错误,没有成功。我哪里错了?

我的代码(index.php)

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="js/jquery.jeditable.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
  $(".dblclick").editable("change.php", { 
    submitdata : {userid: "<?=$id?>"},
     id   : 'elementid',
     name : 'newvalue',
      indicator : "<img src='styles/images/ui-anim_basic_16x16.gif'>",
      tooltip   : "click to edit",
      event     : "dblclick",
      style  : "inherit"
  });
  });
  </script>
...
<div id="fullname" class="dblclick" ><?=$person->fullname?></div>

change.php

<?php
require 'db.php';
$id=$_POST['userid'];
$field=$_POST['elementid'];
$newvalue=$_POST['newvalue'];
if(isset ($id) && isset($field) && isset($newvalue) )
{$query =  $db->query("UPDATE usr_table  SET '$field'='$newvalue' WHERE id = '$id'")  or die(mysqli_errno());
    }
?>

1 个答案:

答案 0 :(得分:2)

尝试将您的代码更改为以下内容:

<?php
require 'db.php';
$id=$_POST['userid'];
$field=$_POST['elementid'];
$newvalue=$_POST['newvalue'];
if(isset ($id) && isset($field) && isset($newvalue) )
{
    $query =  $db->query("UPDATE usr_table  SET '$field'='$newvalue' WHERE id = '$id'")  or die(mysqli_errno());
    echo $newvalue; 
}
?>