0

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";} ?>>
3
Contributors
3
Replies
24
Views
4 Years
Discussion Span
Last Post by davidjennings
0
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"...

Edited by arunmagar

0

Try this

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

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'"; }?>>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.