PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

小弟初学者,问个有关问题,高手帮忙啊

原创
2016-06-13 13:47:17 544浏览

小弟菜鸟,问个问题,高手帮忙啊!!!!!!
小弟欲做一个 点击表格里面的数据后就可以在线编辑。编辑完以后按回车 直接把刚修改的数据入库!!

HTML代码:



$sql="select * from news";
$result=mysql_query($sql);
while($rs=mysql_fetch_array($result))
{
?>
 
 
 
 
 
  }
  ?>
  
echo $rs["name"]?> echo $rs["title"]?>






JQUERY代码:

$(function(){
var numTD = $("tr td:even");
numTD.click(function(){
var input=$("");

input.css("border-width","0");


var tdobj=$(this);
input.width(tdobj.width());


input.val(tdobj.html());
tdobj.html("");
input.appendTo(tdobj);
input.get(0).select();
input.click(function(){
return false ;  
});

input.keyup(function(event){
var keycode = event.which;
var inputtext = $(this).val();

if (keycode == 13){
$.get("http://127.0.0.1:8080//100/jquery/insert.php?name="+inputtext);

}

if (keycode ==27)
{
tdobj.html(text);
}
 
});
});
 
});




PHP代码

$name=$_GET["id"];
$name=$_GET["name"];
$title=$_GET["title"]
$sql="update news set name='$name' where id='$id'";

mysql_query($sql);


运行效果,点击后可以编辑。但回车不能入库。。请高手解决!!!!谢谢了!!

------解决方案--------------------
$name=$_GET["id"]; is this a typo or your intending?
I can't find the place where you input your ID field,

$sql="update news set name='$name' where id='$id'";
but request here somehow.
------解决方案--------------------
$name=$_GET["id"];//链接中没有id
$name=$_GET["name"];
$title=$_GET["title"]//链接中没有title
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。