php - 未返回 set_checkbox 值
问题描述
[在此处输入图像描述][1]我想在单击编辑按钮后使用编辑按钮重新填充我的表单,它将显示要显示的所有选定项目
<input type="checkbox" id="mycheck1" name="certid[]"
value="1" class="cbx" <?php echo set_checkbox('certid','1');?>
控制器
$data['getcert'] = $this->User_Model->getcert();
output should be in the form of array
Array
(
[id] => 1
[certificate_id] => 1
[fee] => 500
[APPNO] => 10001
[regno] => 01107402042
[certid] => 1
[noc] => 2
[paid] => 1000
)
<?php foreach($getcert as $student){
echo '<pre>';
print_r($student);
echo '</pre>';
?>
<td width="50px" align="center">1</td>
<td>Transcripts & Degree Certificate Attestation</td>
<td align="center"><input type="checkbox" id="mycheck1" name="certid[]"
value="<?php echo (!isset($student['certid'])) ? 1 : $student['certid']
?>"
class="cbx" <?php echo set_checkbox('certid[]','1');?> ></td>
<td> 500 </td>
<td> <input type="number" id="primaryincome1" min="1" max="999"
name="noc[]"
value="<?php echo (!isset($student['noc'])) ? '' : $student['noc'] ?>"
disabled> </td>
<div class="col-xs-2">
<td ><input type="text" id="totalamountremaining1" name="txt"
class="text-right" value="<?php echo (!isset($student['paid'])) ? 0 :
$student['paid'] ?>" size="5"></td>
</div>
that certid value only be placed in checkbox
此值存储在 db 中。如何在此视图中分配该值?
解决方案
尝试这个:
<input type="checkbox" id="mycheck1" name="certid[]"
value="1" class="cbx" <?php echo set_checkbox('certid','1', $certid==1;?>>
作为您的$certid
数据库值
从手册:
第三个(可选)参数允许您将项目设置为默认值(使用布尔值 TRUE/FALSE)'
所以你测试你的 db 值是否符合复选框值,就是这样。
推荐阅读
- flutter - Flutter 在变量的值发生变化时执行函数
- here-api - HERE 地图自定义字体
- reactjs - 在 onChange 内带有 e.target.value 的异步 setState
- python - POST 请求(绑定表单)后 Django 表单字段的默认/初始值(必需 = True)
- php - 如何在 Vue/Laravel 中调试 422(无法处理的实体)错误响应?
- flutter - Azure 媒体清单文件我无法在 video_player 颤振包中重现它
- java - Spring集成中的动态路由
- database - Kubernetes 中的以太坊:致命:无法打开数据库:资源暂时不可用
- reactjs - 我无法使用 useEffect 从 api 获取数据
- ios - 使用 Combine 和 URLSession 处理无互联网连接错误