[eluser]PHP Programmer[/eluser]
Hello Everyone,
I am using a form having some dynamic checkboxes that are created by applying a loop over the result fetched from database. I am looking the way of handling these checkboxes that are set to checked or unchecked. More specifically, if I check a checkbox then its DB entry should be changed to '1' and if I uncheck it then entry should be '0'.
I am using following code:
<? foreach ($page['questions'] as $question) { ?>
<tr>
<?php
if($question['active'] == '1') {
$var = "1";
$type = TRUE;
}
else
$var = "0";
$type = FALSE;
?>
<?=form_checkbox("Q_{$question['questionid']}_active",$var,$type) ?>
<?
}
?>
But it is not functioning as desired. It always sets '1'.
Please suggest what is wrong...
TIA
Anuj