如何从jquery-ui对话框更改数据库中的数据? [英] how to change data at DB from jquery-ui dialog?

查看:268
本文介绍了如何从jquery-ui对话框更改数据库中的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手,我想从jquery-ui 对话框中更改我的数据库数据< a>。
我应该添加到对话框脚本中的哪些代码可以在连接到数据库之前连接到进程页面?

i'm newbie,i want change my DB data from jquery-ui dialog. What code should I add to the dialog script that can make me connecting to process page before connecting to DB?

推荐答案

在你的jquery-ui对话框中,你应该让一个按钮,当你按下它,它会更新数据库表中的一行。为了做到这一点:

In your jquery-ui dialog you should have let say a button, and when you press it, it would update a row in a database table. In order to do it:

创建一个按钮,当按下它会触发ajax请求到php文件:

-Create a button, and when pressed it would trigger an ajax request to a php file:

$('#MyButton').click(function() {
 $.ajax({
 type: "GET",
 url: "MyPage.php",
 data: "id=3",
 cache: false,
 error: function (msg) {},
 success: function (msg) {}
 });
});

- 在您的php文件中,您将有一个脚本更新数据库表中的行:

-In your php file you would have a script updating the row in the database table:

<?php
mysql_connect("Host", "Login", "Password) OR trigger_error(mysql_error(), E_USER_ERROR);
mysql_select_db("DatabaseName") OR trigger_error(mysql_error(), E_USER_ERROR);
mysql_query("UPDATE tableName SET myValue = 'value' WHERE condition = 'value'") OR trigger_error($query, E_USER_ERROR);
?>

这是一个很简单的例子,阅读以下教程:

This is a really simple example, I would recommend reading the following tutorials:

http ://php4every1.com/tutorials/jquery-ajax-tutorial/

这篇关于如何从jquery-ui对话框更改数据库中的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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