PHP更新数据库与复选框

时间:2014-02-17 20:41:33

标签: php sql ajax

我是ajax的新手,我尝试更改数据库中的值,等待复选框。我使用以下代码:

<script type="text/javascript">
    function update(id_submit, check){
        check = (check==true ? 1 : 0);
        var url = "check_validate.php.php?id_submit="+id_submit+"&chkYesNo="+check;
            if(windows.XMLHttpRequest){
                req = new XMLHttpRequest();
            }
            else if(windows.ActiveXObject){
                req = new ActiveXObject("Microsoft.XMLHTTP");
            }
                req.open("GET", url, true);
                req.send(null);
        }
</script>  

然后我从我的数据库中获得了另一个值:

    while ($row = mysqli_fetch_array( $result, MYSQL_ASSOC))
    {
    $check = $row['checkbox'];
    $id_submits = $zeile['id_submits']; 

?>
        <td style='text-align:center;width:120px;'>
        <input name="check" type="checkbox" id="check_<?php echo $id_submits; ?>" value="<?php echo $id_submits; ?>" onclick="check(<?php echo $id_submits; ?>, this.checked);" 
        <?php if($check == 1){ echo "checked"; }else{ echo "";} ?>/>
        </td><?php

然后我有了“check_validate.php”

$id_submit = $_GET['id_submit'];
$chkYesNo = $_GET['chkYesNo'];

require_once('config.php');    

$sql = "UPDATE table1
SET checkbox =$chkYesNo WHERE id_submits = $id_submits";
$result = mysqli_query( $link, $sql );

但我的数据库没有任何反应,我做错了什么?

0 个答案:

没有答案