Everyone
My question is so clear I think:
I have an array of checkboxes in HTML
<input type="checkbox" name="gruplar[]" value="<?=$deptId?>">
It takes “value” values from database ID’s e.g. 1,4,5
I can get these values in an array variable named $divided[]. For example 1,4,5 selected and the array is: $divided[0]=1,$divided[1]=4,$divided[2]=5,
When I need to update the record of checkbox list, I want to get this checkbox list selected with these array values.
- Check the checkbox which has “value” of “1”, “4” and “5” according to
the elements of the array.
How can I do that in HTML mixed PHP context?
This checks if the value of the checkbox (as given by $deptId, which I’m assuming is what you meant as you’re echoing it for the value attribute) is in the array $divided. If it is, it echos markup to make the checkbox checked when it is rendered by the browser.