checkbox - keeping multiple checkboxes checked in foreach loop in php -


i have multiple checkboxes within foreach loop , need keep selected checkboxes checked after form submission. code below. please help.

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

now , how include checked property of boxes..

you don't need foreach loop here

this can done checking multiple checkbox checked

  <?php     $i=0;     while ($row=mysql_fetch_array($result,mysql_assoc))     {         $checked = "";         if($row['database_column_name']=$val){             $checked = "checked";         }         echo '          <input type="checkbox" name="chkbx" onclick ="func()" id="'.$id.'" value="'.$val.'" '.$checked.'>'.           $val          .'         ';     }     ?>        

works me.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -