Here is my code. I want to combine both searches into one if I can and still show all functions. Ticked if it exists in permissions table ticked if SetValue is 1 and unticked if 0 or non existent
$result2 = mysqli_query($link2, "SELECT * FROM `member_functions`");
while($row2 = mysqli_fetch_assoc($result2)){
$c = '';
$fID = $row2['ID'];
$result4 = mysqli_query($link2, "SELECT * FROM `member_permissions` WHERE `MemberID` = $ID and `FunctionID` = $fID");
while($row4 = mysqli_fetch_assoc($result4)){
if (mysqli_num_rows($result4) > 0){
if ($row4['SetValue'] == 1){
$c = 'checked';
} else {
$C = '';
}
}
?>
<p>
<label for="email"><b><?php echo $row2['FunctionName']; ?></b></label>
<input type="checkbox" name="<?php echo $row2['ID']; ?>" value="<?php echo $row2['ID']; ?>" <?php echo $c; ?>>
</p>
<?php
}
}
?>