checkbox - keeping multiple checkboxes of the same name checked in foreach loop in php -


i have asked question,but couldn’t find solution.made modification in code.kindly give me solution. need keep selected check-boxes checked after form submission. code below. please help.

     <? $i=0;         while ($row=mysql_fetch_array($result,mysql_assoc))         {              $id="chkbox".$i;       ?>           <input type="checkbox" name="chkbx" onclick ="func()" id="<?echo   $id;">? value="<?echo $val \n;?>" <? echo "$val";?>      <? $i=$i+1       }      ?> 

now , how include checked property of boxes..

use attribute "checked" selected checkboxes , add [] name attribute convert single attribute array of values:

<input type="checkbox" checked="checked" name="chkbx[]" ...... > 

Comments