Checkbox state is opposite of boolean value?

I have the following code that should mark a checkbox as checked if the query returns 1 :

<?php
$isAdmin = (bool)$isAdmin; //1 = true, 0 = false
$checked = ($isAdmin) ? 'checked="checked"' : '';
?>
    <td><input type="checkbox" name="isAdmin" value="1" <?php echo $checked; ?> /></td>
</tr>

The problem is, when I open the form, if isAdmin = 1, the checkbox is unchecked, and if isAdmin = 0, it is checked. It should be opposite.

I know I could simply swap

$checked = ($isAdmin) ? 'checked="checked"' : '';

for this

$checked = ($isAdmin) ? '' : 'checked="checked"';

However, shouldn't this work as if true then else instead of if false then else?


Solution 1:

The current code provided works when manually setting $isAdmin to 1, review what this value is set as to determine the issue.