【发布时间】:2010-12-17 02:08:08
【问题描述】:
【问题讨论】:
标签: mysql html database ajax checkbox
【问题讨论】:
标签: mysql html database ajax checkbox
使用jQuery 和 PHP。
这是 jQuery 中的an example:
$.post("test.php", { isChecked:$('#checkbox_id').attr('checked') } );
此语句应在 <head></head> 或单独的 JavaScript 文件中定义。
在您的 PHP 代码中,您可以检查 isChecked POST 变量:
if($_POST('isChecked')==1)
{
//Set MySQL table to 1.
}
else
{
//Set MySQL table to 0.
}
这里是a reference on how to use post。这是how you can use PHP to update MySQL table。
【讨论】:
<head></head> 或单独的 js 文件中定义它
您使用复选框的 onchange 事件处理程序向某些服务器端代码发出 XmlHttpRequest 以更新您的表格。
【讨论】: