jEditable - 更新新的价值观数据库 [英] jEditable - update new values to database

查看:200
本文介绍了jEditable - 更新新的价值观数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个新手到Web开发的世界。让我来解释我想要什么。

i'm a newbie to web development world. Let me explain what i want.

id  car        make 
1   panamera   porsche  
2   italia     ferraris 
3   avantador  lamborghini  
4   slk        mercedes

我有这个简单的表在我的数据库,我要去回应此表在一个while循环。

I have this simple table in my database and i'm gonna echo this table in a while loop.

<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="jquery.jeditable.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>
<ul>
<?php  
$query = "SELECT * FROM inplace LIMIT 0, 6";    
$result = mysql_query($query) or die ('Query couldn\'t be executed');  
while ($row = mysql_fetch_assoc($result)) {
?>

<script type="text/javascript">
$(function() {
$("#<?php echo $row['id']; ?>").editable("http://www.example.com/save.php", { 
  indicator : "<img src='img/indicator.gif'>",
  tooltip   : "Doubleclick to edit...",
  event     : "click",
});
});
</script>

<?php
echo '<li id="'.$row['id'].'">'.$row['car'].'</li>';
echo '<li id="'.$row['id'].'">'.$row['make'].'</li>'; 
}
?>
</ul>
</body>

我试图用米卡Tuupola的jEditable编辑就地jQuery插件。在这里,在这个code,我有jQuery的code while循环中粘贴。这里的第一个问题是,只有车列可编辑。我不能编辑做一栏。其次,如何发布(更新)新值的数据库?谢谢你。

I'm trying to use Mika Tuupola's jEditable edit-in-place jQuery plugin. Here in this code, i have the jQuery code pasted inside the while loop. The first problem here is, only the "car" column is editable. I'm not able to edit the "make" column. And secondly, how do i post(update) the new values to database? Thanks.

推荐答案

您使用的是两个元素具有相同的ID,这既是语义和逻辑不正确。因此,它不工作,你的预期。

You are using two elements with same id, which is both semantically and logically incorrect. Hence it is not working as you expected.

要么给相同的类或differenct的ID像显示在下面的示例

Either give same class or differenct ID's like shown in the following example.

echo '<li id="car'.$row['id'].'">'.$row['car'].'</li>';
echo '<li id="make'.$row['id'].'">'.$row['make'].'</li>';

这篇关于jEditable - 更新新的价值观数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆