php - 第二个单选按钮始终显示在 PHP 中选中
问题描述
我的页面和代码下方有单选按钮,我正在使用它。如果我将数据插入数据库,那么它会发送正确的值。
现在,我的问题是,我在编辑页面上,每次,女性单选按钮都显示为选中状态。我不知道为什么。我正在1
从数据库中获取价值。
另外,我注意到如果我删除它,isset()
那么它可以工作,但我不想删除它。如果我删除isset()
然后我在编辑页面上收到错误
注意:尝试访问 bool 类型值的数组偏移量
<?php $info['profile']['gender']=1;?>
<div class="form-check ps-0">
<input type="radio" id="male" class="radio-custom" name="gender" value="1" <?php if(isset($info['profile']['gender'])==1){?> checked="checked" <?php }?>>
<label for="male" class="radio-custom-label">Male</label>
</div>
<div class="form-check">
<input type="radio" id="female" class="radio-custom" name="gender" value="2" <?php if(isset($info['profile']['gender'])==2){?> checked="checked" <?php }?>>
<label for="female" class="radio-custom-label">Female</label>
</div>
解决方案
推荐阅读
- kubernetes - 如何正确连接 K8S 对象?
- php - Laravel API 返回文件并且客户端必须显示下载对话框
- javascript - 在页面上找不到我的 jQuery?它是否在其他元素后面显示加载的数据?
- azure-devops - Azure Devops Pipeline 测试步骤失败 - 数据文件的路径不正确
- asp.net - 在 ActionFilterAttribute 中添加标题
- python-2.7 - Python鼻子测试覆盖包并排除一些目录
- javascript - 如何使用 setInterval 函数在屏幕上显示的每个值之间以 500 毫秒的间隔显示阶乘计算?
- javascript - 在每个单元格上动态添加两个不同的按钮
- kendo-ui - Kendo Grid 中的动态过滤器
- c# - 如何在 C# 中追加和更新 cookie?