代碼如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Demo </TITLE>
</HEAD>
<BODY>
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
function clickImg(){
$.ajax({
type:"post", //提交類型
url:"demo.php", //提交頁面
//data:"row="+row,
success:function(msg) {
$("#number").text(msg);
} //成功則輸出
});
}
</script>
<span id="demo"><img src="c:\00.png" id="img" name="img" onclick="clickImg()" /></span>
<span id="number"></span>
</BODY>
</HTML>
以上是HTML頁面代碼
代碼如下:
<?php
$link = mysql_connect('192.168.1.11','root','12345');
mysql_select_db("mltest", $link);
$strlan = mysql_query("UPDATE newtable SET click = click +1 WHERE id='1'");
$str = mysql_query("select click from newtable WHERE id = '1'");
while($row = mysql_fetch_array($str))
{
echo $row['click'];
}
?> // 對數據庫進行操作,並返回值
以上的PHP頁面代碼。
使用的是jquery1.4.1版類庫