我有一个带有两个文件的复选框简单表单,在提交时我在数据库中提交值yes或no,现在在编辑中我想显示该复选框被选中。
<div class="form-group col-md-6">
<label> Is Paid</label></br>
Yes <input type="checkbox"
name="paid"
value="yes"
value=" <?php echo $row_cat['is_paid']; ?>"
/>
No <input type='checkbox' name="paid" value="no" />
</div>
如何在编辑页面上显示预填充复选框?
答案 0 :(得分:1)
尝试
<div class="form-group col-md-6">
<label> Is Paid</label></br>
Yes <input type="checkbox"
name="paid"
value="yes"
<?php echo $row_cat['is_paid']=='yes'?' checked="checked" ':''; ?>
/>
No <input type='checkbox'
name="paid"
value="no"
<?php echo $row_cat['is_paid']=='no'?' checked="checked" ':''; ?>
/>
</div>