I have the following in a form that edits values already put into a dbase.
$alev = array(1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => 'AP');
$dblev = explode(',',$row['hw_lev']);
foreach ($alev as $key => $lev){
if(in_array($lev,$dblev)){
echo "<input type='checkbox' name='ud_lev[]' value='$lev' checked> $lev";
}
else {
echo "<input type='checkbox' name='ud_lev[]' value='$lev'> $lev";
}
When I attempt to edit the dbase values, the following occurs:
When I select the "A" checkbox, it is input into the database and reflects in the results. When I attempt to edit this, the "A" box is checked and all is well.
When I select anything else AND "A" ("1", "A"), it is input into the database and reflects in the results. When I attempt to edit this, the "1" box is checked but the "A" box is NOT checked. This is what I need.
I feel like the problem is with the array? But it could be the loop.. Probably something totally staring me in the face. You know how it goes. I was wondering if you see a problem in the array or in the loop. Any thoughts would be appreciated!