Nie powinieneś tego samego id więcej niż raz na stronie.
I umieść atrybut wartości w '
<?php
foreach ($values as $value) {
$selected = in_array($value, $db_values) ? ' checked="checked"' : null;
echo "<input type='checkbox' name='sports[]' id ='sport' value='" . $value ."' " . $selected . "/>" . $value . "<br />";
} ?>
Utwórz tablicę w ten sposób
$arr['F'] = "Football";
$arr['R'] = "Rugby";
$arr['C'] = "Cricket";
$arr[$value] instead of $value
EDYTUJ
<?php
$arr['F'] = "Football";
$arr['R'] = "Rugby";
$arr['C'] = "Cricket";
foreach ($values as $value) {
$selected = in_array($value, $db_values) ? ' checked="checked"' : null;
echo "<input type='checkbox' name='sports[]' id ='sport' value=" . $value . $selected . "/>" . $arr[$value] . "<br />";
}
?>