Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/368.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何启用此代码的就地编辑..因此我需要在update.php文件中更新该值_Javascript_Php_Jquery - Fatal编程技术网

Javascript 如何启用此代码的就地编辑..因此我需要在update.php文件中更新该值

Javascript 如何启用此代码的就地编辑..因此我需要在update.php文件中更新该值,javascript,php,jquery,Javascript,Php,Jquery,如何为以下代码启用就地编辑 View.php: View.php: 当您更改HTML页面上的值时,是否要自动更新数据库的内容?@davideastore是的,一旦用户编辑字段,我需要更改数据库中的值 <?php include('path.php'); $cid=$_POST['id']; $cnum=$_POST['chapternumber']; $cname=$_POST['chaptername']; $dbh = new PDO($dir) or

如何为以下代码启用就地编辑

View.php:


View.php:


当您更改HTML页面上的值时,是否要自动更新数据库的内容?@davideastore是的,一旦用户编辑字段,我需要更改数据库中的值
 <?php
 include('path.php');
 $cid=$_POST['id']; 
 $cnum=$_POST['chapternumber'];
 $cname=$_POST['chaptername']; 
        $dbh  = new PDO($dir) or die("cannot open the database"); 
        $query =  "update CHAPTER set `CHAPTER_NUMBER`='".$cnum."',`CHAPTER_NAME`='".$cname."' WHERE ID=".$cid; 
        $dbh->exec($query);      
  ?>
$('.td_edit').blur(function() {
  var parent = $(this).parent();
  var id = parent.data('id');
  var spans = parent.find('span.text');
  var cnum = spans.eq(0).text();
  var cname = spans.eq(1).text();

  var dataToSend = {
    id: id,
    chapternumber: cnum,
    chaptername: cname
  };
  $.post( "Update.php", dataToSend, function( data ) {
    console.log("Check the result %o", data);
  });
});