Du skal ikke have samme id mere end én gang på en side.
Og omslut værdiattribut med '
<?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 />";
} ?>
Opret array som denne
$arr['F'] = "Football";
$arr['R'] = "Rugby";
$arr['C'] = "Cricket";
$arr[$value] instead of $value
REDIGER
<?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 />";
}
?>