且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用jQuery / AJAX更新MYSQL

更新时间:2023-02-11 19:17:09

可以说,上面的PHP code在文件中,update.php。然后你可以用下面的code -

Lets say the above PHP code is in file, update.php. Then you can use the following code -

<head>
<script src="jquery.js"></script>
<script>
  function UpdateRecord(id)
  {
      jQuery.ajax({
       type: "POST",
       url: "update.php",
       data: 'id='+id,
       cache: false,
       success: function(response)
       {
         alert("Record successfully updated");
       }
     });
 }
</script>
</head>
<body>
<input type="button" id="button_id" value="Update" onClick="UpdateRecord(1);">
</body>

只是通过有效身份证件在UpdateRecord功能。把你的PHP code。在update.php文件。只要是在一个更安全的一面,你的PHP code替换 $ VAR = @ $ _ GET ['身份证']; $ VAR = @ $ _ POST ['身份证']; 和检查,如果这对你的作品

Just pass a valid id in the UpdateRecord function. Put your PHP code in update.php file. Just to be on a safer side, in your PHP code replace $var = @$_GET['id'] ; with $var = @$_POST['id'] ; and check if this works for you