jeudi 27 octobre 2016

how to get checkbox value as checked from database in php?

in database values are stored as "A,B,C,D,E,F" etc. now i have to fetch those data in the form for update. i have to check the checkbox if it matches the value with database value.

$rs=sql("select sectionName from sections where sectionName != ' ' order by     sectionName");
$cat_options="";
    foreach($rs as $d){
        $option=$d['sectionName'];
        $cat_options.= "<label><input type='checkbox' name='category[]' value='$option'>$option</label><br/>";
    }

It retrieve list of category from one table.

$a = explode(",", $category);

$a is array of name of category that should be checked in list of category.

I already knew that there are lots off topics on net related to my topics. I tried them but no luck.




Aucun commentaire:

Enregistrer un commentaire