Javascript 如何启用此代码的就地编辑..因此我需要在update.php文件中更新该值
如何为以下代码启用就地编辑 View.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:
当您更改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);
});
});