在php中获取check / unchecked“复选框”

时间:2016-07-12 06:29:10

标签: php html5 algorithm

我编写了以下代码片段来编辑或更新我的权限,这样当我点击编辑按钮时,就会出现勾选/取消选中复选框。

<?php
}
}
$id=$_REQUEST['user'];
if(isset($_GET['showtab']) && $_GET['showtab']==1) {
$result=doQuery("SELECT user,
                        account,
                        firstname,
                        lastname,
                        branchname,
                        username 
                        FROM web_webusers WHERE user='".(int)$id."'");
$test = mysql_fetch_array($result);

            $user=$test['user'];
            $firstname=$test['firstname'];
            $lastname=$test['lastname'];
            $branchname=$test['branchname'];
            $username=$test['username'];

$result=doQuery("SELECT user,
                        AllowAddAddressBook,
                        AllowEditAddressBook,
                        AllowAddPrealert,
                        AllowEditPrealert,
                        AllowAddUser 
                        FROM web_clientuser_permission WHERE user='".       (int)$id."'");
$test = mysql_fetch_array($result);

            $user=$test['user'];
            $AllowAddAddressBook=$test['AllowAddAddressBook'];
            $AllowEditAddressBook=$test['AllowEditAddressBook'];
            $AllowAddPrealert=$test['AllowAddPrealert'];
            $AllowEditPrealert=$test['AllowEditPrealert'];
            $AllowAddUser=$test['AllowAddUser'];
}

?>
<div class="row">
     &GT;      &GT;允许添加地址簿
 <div class="col-sm-6">
 <input type="hidden" name="AllowEditAddressBook" id="AllowEditAddressBook" value="0"<?php echo ($AllowEditAddressBook==1) ?  ' check' : '' ?>>
 <label><input type="checkbox" name="AllowEditAddressBook" id="AllowEditAddressBook" value="1">&nbsp;Allow Edit Address Book</label>


           &GT;      &GT;允许添加预警     

     &GT;      &GT;允许编辑预警      
 <div class="col-sm-6">
<input type="hidden" name="AllowAddUser" id="AllowAddUser" value="0" <?php echo ($AllowAddUser==1) ?  ' check' : '' ?>>
 <label><input type="checkbox" name="AllowAddUser" id="AllowAddUser" value="1" <?php echo ($AllowAddUser==1) ?  ' check' : '' ?>>&nbsp;Allow Add User</label>
</div>
</div>
<br>


<center>
<button type="submit" name="saveuserinfo" value="1" class="btn btn-success"><i class="icon-save icon-large"></i>&nbsp;Save</button>
<center></div>

是否有可能实现我的要求?关于如何实现我要求的概念的任何意见将不胜感激。

提前致谢!

1 个答案:

答案 0 :(得分:0)

请参阅此处的教程以获得更广泛和更清晰的解释 https://www.formget.com/php-checkbox/