vendredi 21 octobre 2016

Checkbox not selected based on database value

I have 3 checkboxes.These values are saved in db with comma like 1,2,3(select three).In edit i want to select the three checkboxes.But its not done

view

 <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 value like 1,2,3

Anyone please help me




Aucun commentaire:

Enregistrer un commentaire