单击表格修改框内的值并在数据库修改

html部分
html表格部分用php for循环渲染
js
$(function(){


$('table td').click(function(){
if(!$(this).is('.input')){
$(this).addClass('input').html('').find('input').focus().blur(function(){
var thisid = $(this).parent().siblings("th:eq(0)").text();
var thisvalue=https://www.it610.com/article/$(this).val();
var thisclass = $(this).parent().attr("class");


$.ajax({
type: 'POST',
url: 'update.php',
data: "thisid="+thisid+"&thisclass="+thisclass+"&thisvalue="https://www.it610.com/article/+thisvalue
});
$(this).parent().removeClass('input').html($(this).val() || 0);
});
}
}).hover(function(){
$(this).addClass('hover');
},function(){
$(this).removeClass('hover');
});
});


数据库


require "conn.php";
$id = trim($_REQUEST['thisid']);
$thisclass = trim($_REQUEST['thisclass']);
$thisvalue= https://www.it610.com/article/trim($_REQUEST['thisvalue']);
if (substr_count($thisclass," ")>0){
【单击表格修改框内的值并在数据库修改】$thisclass=str_replace(" ","",$thisclass);
}
if (substr_count($thisclass,"input")>0){
$thisclass=str_replace("input","",$thisclass);
}
$update_sql = "update add_delete_record set $thisclass='$thisvalue' where id='$id'";
$result = mysqli_query($con,$update_sql);

    推荐阅读