Hi,
Following situation: I stored a checkbox array with implode in a mysql table field. Now, in order to update the checkboxes, I want to read the table field content, explode it into its parts and assign it to the respective checkboxes.
So far I managed to read out and explode the table field content into different chunks, my difficulty is how to assign to the respective checkboxes.
Here is the checkbox field:
<tr>
<td><input class="field checkbox" type="checkbox" name="appbox[]" value="Automotive" <?php $appbox_checked ?> /><label class="choice">Automotive</label></td>
<td><input class="field checkbox" type="checkbox" name="appbox[]" value="Backlights" <?php $appbox_checked ?> /><label class="choice">Backlights</label></td>
<td><input class="field checkbox" type="checkbox" name="appbox[]" value="LED lighting" <?php $appbox_checked ?> /><label class="choice">LED lighting</label></td>
</tr>
<tr>
<td><input class="field checkbox" type="checkbox" name="appbox[]" value="IR" <?php $appbox_checked ?> /><label class="choice">IR</label></td>
<td><input class="field checkbox" type="checkbox" name="appbox[]" value="Signage/Traffic Lights" <?php $appbox_checked ?> /><label class="choice">Signage/Traffic lights</label></td>
<td><input class="field checkbox" type="checkbox" name="appbox[]" value="Mobile Devices" <?php $appbox_checked ?> /><label class="choice">Mobile devices</label></td>
</tr>
and here is the php code:
$storebox = explode(", ", $chunk0);
for($i = 0; $i < count($storebox); $i++){
echo "Piece $i = $storebox[$i] <br />";
}
The chunk content matches the value field of the checkbox. So what I need is basically:
if 'chunk content' = 'checkbox value'
then <?php $appbox_checked ?>
will echo 'checked'
Or maybe there is a simplier solution. Thanks for you help guys!