Hello
i have checkbox like this at update form but it's appear unchecked
<input type="checkbox" name="years[]" id="years" value="<?php echo $key; ?>" >
i want if it has value at database appear checked
any help?
Hello
i have checkbox like this at update form but it's appear unchecked
<input type="checkbox" name="years[]" id="years" value="<?php echo $key; ?>" >
i want if it has value at database appear checked
any help?
// select from database and assign it in some variable
if($key == $res['years']) // compare it with looping $key
$checked = 'checked="checked"';
else
$checked = '';
<input type="checkbox" name="years[]" <?php echo $checked; ?> id="years" value="<?php echo $key; ?>" >
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.