0
我有3個複選框。這些值用逗號保存在數據庫中,如1,2,3(選擇三)。在編輯中,我想選擇三個複選框。但它沒有完成。未根據數據庫值選擇複選框
視圖
<label class="control-label"> Select Group:</label> </span>
<div class="controls">
<span class="details">
<input type="checkbox" name="group[]" value="1" <?php if(in_array('1', explode(",",$students_list->group_list))) echo('selected = "selected"'); ?> />one
<input type="checkbox" name="group[]" value="2" <?php if(in_array('2', explode(",",$students_list->group_list))) echo('selected = "selected"'); ?>/>two
<input type="checkbox" name="group[]" value="3" <?php if(in_array('3', explode(",",$students_list->group_list))) echo('selected = "selected"'); ?>/>three
<?php echo form_error('group'); ?>
</span>
</div>
$students_list->group_list
值樣1,2,3
嘗試使用'「選中」「而不是」「選中=」選中「 – Blinkydamo