How does php output the check box? There are 6 check boxes in the form. if 126th check boxes are selected, the data inventory is 1, 2, and 6.
Now the question is, how can I use php to set the value from the database on the modified page and output 6 check boxes so that 126 is checked?
Reply to discussion (solution)
$ Row ['id'] = 1;
>
I mean how to output 6 check boxes after obtaining values 1, 2, and 6 from the database so that 126th check boxes are selected by default and 345 check boxes are not selected,
The difficulty lies in the fact that the insert is not selected in the middle.
I mean how to output 6 check boxes after obtaining values 1, 2, and 6 from the database so that 126th check boxes are selected by default and 345 check boxes are not selected,
The difficulty lies in the fact that the insert is not selected in the middle.
Set the checked attribute corresponding to the check box you selected (for example, corresponding to 1, 2, 6.
If your data inventory is 1, 2, 6, you can directly set the name or id of the corresponding check box to the corresponding, and then you can directly access the checkbox that needs to change the status
I mean how to output 6 check boxes after obtaining values 1, 2, and 6 from the database so that 126th check boxes are selected by default and 345 check boxes are not selected,
The difficulty lies in the fact that the insert is not selected in the middle.
Make an if judgment. values equal to 1, 2, and 6 are checked, and values not checked.
echo "";echo "";echo "";echo "";echo "";echo "";
$arr=array(1,2,6);for($i=0;$i<6;$i++){ $checked=in_array($i+1,$arr) ? 'checked' : ''; echo "\n";}
...
Database values
$ A = '1, 2, 6 ';
How do I write in if brackets?
"/>
"/>
"/>
"/>
"/>
"/>
$ A = '1, 2, 6 ';
$ Ar = explode (',', $ );
$ I = 0;
?>
/>
/>
/>
/>
/>
/>
Finally, thanks to Daniel upstairs.