gpt4 book ai didi

php - 使用 onclick 按钮更新数据库信息

转载 作者:行者123 更新时间:2023-11-29 14:47:39 25 4
gpt4 key购买 nike

我需要有关按钮 onClick 的帮助。

<button type="button" id="1" onclick="this.disabled=true; ^FUNCTION TO UPDATE^"> 
<button type="button" id="2" onclick="this.disabled=true; ^FUNCTION TO UPDATE^">
<button type="button" id="3" onclick="this.disabled=true; ^FUNCTION TO UPDATE^">

使用此代码,我禁用了按下的按钮,但我还需要更新发送 ID 的数据库中的信息,如下所示:

UPDATE reservation SET status='approved' WHERE id=^ID OF THE CLICKED BUTTON^

我需要将其加载到同一页面中,而不用 POSTGET 发送。

最佳答案

为此使用 ajax 调用,例如:

$.get('update_reservation.php', {id: 1});

参见http://api.jquery.com/jQuery.get/了解更多信息。

关于php - 使用 onclick 按钮更新数据库信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6559868/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com