<td><input type="checkbox" name="cb" /></td>
how i get this checkbox checked based on my database content
on my database field the contents is 1 and 0
if 1 checkbox will checked
and if 0 checkbox unchecked
How i do that
in my view i have 5 checkbox……
1 2 3 4 5
1.[] [] [] [] []
2.[] [] [] [] []
3.[] [] [] [] []
4.[] [] [] [] []
my field status on database……..
| Status |
| 1,2,3 |
| 1,2,3,4,5 |
| 2,3,4 |
| 1,2,5 |
Updatee
how i get checked checkbox
<?php $j=1; foreach ($dudu as $row2 ): ?>
<td><input type="checkbox" name="popok[]"
<?php if(strrpos($row->menu_allowed,''.$j.'')!==FALSE){echo 'checked';$j++;}/></td>
<?php endforeach; ?>
if the data 1,2,3,4 it will check
1 2 3 4
[v] [v] [v] [v]
but if the data not sequential like 1,3,4 it only check the first box
1 3 4
[v] [] []
in your controller get the chek box value
then in your view
UPDATE
use
strrposthis will check
1another method using a for loop
http://php.net/manual/en/function.strrpos.php