Home  >  Article  >  Backend Development  >  小弟初学者,问个有关问题,高手帮忙啊

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

WBOY
WBOYOriginal
2016-06-13 13:47:17755browse

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

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
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn