How do I make dynamic checkboxes sticky

Hi everyone, I have been trying a lot to make my dynamically generated checkboxes sticky. My latest attempt being the code below, but it only prechecks the checkboxes, it doesn’t make them sticky.

I also tried making a condition checking whether the chosen was equal to relation, but I must have written it wrong since it didn’t work at all. Hope you have some suggestions. Thanks in advance…

<?php $sql2 = "SELECT relation FROM table_rel_info"; $result2 = @mysqli_query($dbc, $sql2); while($row2 = mysqli_fetch_array($result2, MYSQLI_ASSOC)) { echo "" . $row2['relation'] . ""; echo " <?php if (isset($row2['relation'])) { echo 'checked="checked"'; }?> <?php echo "'/>" . "
"; } ?>
Sponsor our Newsletter | Privacy Policy | Terms of Service