I am trying to make a checkbox have the checked option depending on a field in my database, if it is 1 that is checked but, do not have it, for this I am using a conditional, I use the foreach to fill the rows from the table:
code
<?php foreach($approved->result() as $key){ ?>
<tr class="text-center">
<td class="blue"><?php echo $key->request_num_case;?></td>
<td class="blue"><?php echo $key->request_made_by;?></td>
<td class="blue"><?php echo $key->request_date;?></td>
<td class="blue"><?php echo $key->fk_roster_salesforcename;?></td>
<td class="blue"><?php echo $key->fk_incidence_name;?></td>
<td class="blue"><?php echo $key->request_incidence_date;?></td>
<td class="blue"><?php echo $key->request_updated_by;?></td>
<td class="blue"><?php echo $key->request_auth_date;?></td>
<td class=" <?php
if ($key->request_resolution == "approved") {
echo "text-success";
}
?>
"><?php $str = strtoupper($key->request_resolution); echo $str;?></td>
<td class="blue"><?php echo $key->request_unread_buga;?></td>
<?php if($key->request_unread_buga == "1"){?>
<td class="blue"><input type="checkbox" checked></td>
<?php} else{?>
<td class="blue"><input type="checkbox"></td>
<?php}?>
<td class="blue">
<form class="" action="<?php echo base_url(); ?>index.php/Buga/detailIncidence" method="post">
<input type="text" name="CaseNumber" value="<?php echo $key->request_num_case;?>" class="display">
<input type="submit" name="detailsBtn" value="Details .." class="btn tlBack whitecol-lg-2 white" id="detailsBtn">
</form>
</td>
I get this error when I put the following lines:
<?php if($key->request_unread_buga == "1"){?>
<td class="blue"><input type="checkbox" checked></td>
<?php} else{?>
<td class="blue"><input type="checkbox"></td>
<?php}?>
error:
If I do not put these lines, I do not get an error and as you can see if it assigns me what is in the column (request_unread_buga, which is the one that says check) that the conditional depends on.
with the code of the conditional according to this case the checkboxes should be checked, since no row of that column has the value 1, I should not leave that error or I am failing, and I really need those checkboxes