Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.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
Mysql 表-保存到数据库_Mysql_Jquery_Jeditable_Edit In Place - Fatal编程技术网

Mysql 表-保存到数据库

Mysql 表-保存到数据库,mysql,jquery,jeditable,edit-in-place,Mysql,Jquery,Jeditable,Edit In Place,我是这个社区的新手。寻求你的帮助做Mika Tuupola的绝地表。 我只想将数据保存到数据库中,并在页面上显示更改。下面是我的代码- <head> <script src="js/jquery-1.7.1.js" type="text/javascript" charset="utf-8"></script> <script src="js/jquery.jeditable.js" type="text/javascript" charset="utf

我是这个社区的新手。寻求你的帮助做Mika Tuupola的绝地表。 我只想将数据保存到数据库中,并在页面上显示更改。下面是我的代码-

<head>
<script src="js/jquery-1.7.1.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.jeditable.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">

$(document).ready(function() {
$("#editab").editable("insert.php", { 
id   : 1,
content : 'editab',
indicator : "<img src='img/indicator.gif'>",
tooltip   : "Doubleclick to edit...",
event     : "click",
height    : 'auto',
onblur    : 'submit',
});
});

</script>
</head>

<body>
<div style="width:640px" class="editable" id="editab">sdfsdf</div>
</body>
</html>

$(文档).ready(函数(){
$(“#editab”).editab(“insert.php”,{
id:1,
内容:'editab',
指标:“,
工具提示:“双击以编辑…”,
事件:“点击”,
高度:“自动”,
onblur:'提交',
});
});
sdfsdf
下面是用于插入数据库的php代码-

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("my_db", $con);  

$id      = $_POST['id'];
$content = $_POST['content'];
mysql_query("INSERT INTO editable (id, content)
VALUES ('$id', '$content')");

echo $content;
mysql_close($con);
?> 

Jeditable插件用于内联编辑内容。根据您的代码,“OnBlur”事件将把您的数据提交到insert.php,因此在insert.php文件中,您必须编写一些代码以将其保存在数据库中

$name = $_REQUEST['id']; // get from request and store your data in variable

$query="insert into data SET 
                    name = '".$name."'; //write db query to save it in db

    mysql_query($query) or die(mysql_error()); //execute your query
   echo 'ok'; //for acknowledgement