Du bör inte ha samma id mer än en gång på en sida.
Och bifoga värdeattributet 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 />";
} ?>
Skapa array så här
$arr['F'] = "Football";
$arr['R'] = "Rugby";
$arr['C'] = "Cricket";
$arr[$value] instead of $value
REDIGERA
<?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 />";
}
?>