Hi All - I am trying to find a solution to the following

I am trying to update a form with checkboxes and to compare the value of the data variable $active from the db and if the value =1 then make the checked value as checked if = to 1 otherwise leave unchecked state.
The unchecked value is zero

Thanks in advance
D

   <input type="checkedbox" class="active"  name = "active" id="active" value="1"  <?php if ($active) == '1'; {"checked = checked";} ?>>

Recommended Answers

All 3 Replies

if ($active == '1')
{  
?>
<input type="checkbox" class="active"  name = "active" id="active" value="1" checked = "checked">
<?php 
}
else
{
?>
<input type="checkbox" class="active"  name = "active" id="active" value="1">
<?php 
}
?>

Please Use above snippet. Also in your code snippet I found <input type="checkedbox"...
For check box it should be <input type="checkbox"...

Try this

<input type="checkbox" class="active"  name = "active" id="active" value="1" <?php if ($active == '1') echo 'checked'; ?>>

Code rum thanks for the reply

eventually got there myself slightly different on the end

Thanks
again

   <input type="checkbox" class="active"  name = "active" id="active" <?php if($active == 1) {echo "checked='checked'"; }?>>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.