conn.php
<?php
$conn = @mysql_connect('127.0.0.1','root','root');
if (!$conn) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('test', $conn);
?>
index.php
<!DOCTYPE html>
<html>
<head>
<title>register.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<script type="text/javascript" src="jquery-3.2.1.min.js"></script>
<script type="text/javascript">
function btn(){
var name=$("#name").val();
$.ajax({
type:"POST",
url:"jia.php",
dataType:"JSON",
data:{
"name":name,
}
})
}
</script>
<input id="name" name="name" type="text" />
<input id="register" type="button" value="操作" onclick="btn()" />
</body>
</html>
jia.php
<?php
require_once("conn.php");
header('content-type:application/json');
$name=$_POST['name'];
//$oid=addcslashes($_POST['oid']);
// $sql="update test set xingqi=(xingqi+1) where id = '$oid'";
$sql="delete from `test` where id = '$name'";
$result = mysql_query($sql);
if($result){
return true;
}else{
return false;
}
?>
AJAX静态更新mysql
最新推荐文章于 2023-05-05 18:27:33 发布