I am getting array to string conversion error , and also here i am able to get first value from database
<label for="#" class="col-sm-2 control-label">test</label>
<div class="col-sm-6">
<?php
$c_box1=$c_box2=$c_box3=$c_box4=$c_box5='';
// $chk_box_data is which is from DB
foreach($selectdata as $r)
{
$list=explode(',',$r->facilities);
echo $list;
if($list=='1'){$c_box1='checked';}
if($list=='2'){$c_box2='checked';}
if($list=='3'){$c_box3='checked';}
if($list=='4'){$c_box4='checked';}
if($list=='5'){$c_box5='checked';}
}
?>
<div class="col-sm-6 checkbox"><input id="checkbox5" type="checkbox" name="test[]" value="1" <?php echo $c_box1;?>><label for="checkbox5" >check</label></div>
<div class="col-sm-6 checkbox"><input id="checkbox1" type="checkbox" name="test[]" value="2" <?php echo $c_box2;?>><label for="checkbox1">check</label></div>
<div class="col-sm-6 checkbox"><input id="checkbox2" type="checkbox" name="test[]" value="3" <?php echo $c_box3;?>><label for="checkbox2">check</label></div>
<div class="col-sm-6 checkbox"><input id="checkbox2" type="checkbox" name="test[]" value="4" <?php echo $c_box4;?>><label for="checkbox3">check</label></div>
<div class="col-sm-6 checkbox"><input id="checkbox2" type="checkbox" name="test[]" value="5" <?php echo $c_box5;?>><label for="checkbox4">check</label></div>
</div>
$list=explode(',',$r->facilities);this line will give you an array. and you are treating as a stringif($list=='1'){$c_box1='checked';}. That's why you are getting errorvar_dump($r->facilities);- post it pls