我有一个表呼叫user
。下面是数据:jquery当mysql表数据更新时立即显示最新数据
+----------+----------+
| ID | money |
+----------+----------+
| 1 | 100 |
| 2 | 200 |
+---------------------+
我t.php
代码如下所示:
//above is connect to db, so I ignore to paste here.
$queryUser = DB::query("SELECT * FROM ".DB::table('user')." WHERE uid = '1'");
while($rowUser = DB::fetch($queryUser)) {
$moneyN = $rowUser['money'];
}
if($_GET['act'] == 'add'){
$moneyadd = $moneyN + 10;
DB::query("UPDATE ".DB::table('user')." SET money = '$money' WHERE uid = '1'");
}
我t.html
编码:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;">
<title>Testing</title>
</head>
<body>
<?php echo $moneyN; ?><br/><a href="t.php?act=add">Go</a>
</body>
</html>
如何我只是使用jQuery更新数据库,并显示最新数据在<?php echo $moneyN; ?>
没有刷新网页?我在谷歌上找到一些教程,但无法工作。
使用'AJAX' http://www.w3schools.com/jquery/ajax_ajax.asp – Samir