[eluser]jigarjain[/eluser]
I am facing a really strange problem which i am debugging from past 2 hours but unable to find the solution. Before explaining the problem, let me show the code
My Controller Function is
Code:
$this->load->library('datatables');
$actionLinkBar = $this->load->view("content/updates/dt_files/action_bar", array(), TRUE);
$this->datatables
->select("id, name, status")
->where('id', $this->session_data['user_id'])
->from("t_user")
->add_column("action", $actionLinkBar, 'id, name, status');
echo $this->datatables->generate();
And the code in my action_bar view is
Code:
<?php
$status_rec = '$3';
var_dump($status_rec); // STRANGE OUTPUT - string(2) "1"
?>
<div class="action_bar" data-update-id="<?php echo '$1'; ?>">
<?php if ($status_rec == '1') { ?> // HENCE COMPARISON ALWAYS FAILS
<span>Present</span>
<?php }else { ?>
<span>Absent</span>
<?php } ?>
</div>
Now explaining the problem.. I am using Datatables with Codeigniter. I have a view template action_bar which will be displayed in one of the columns of datable in front end. The view has if/else condition based on value of status field from DB. If status feild = value 1 = Present Else Absent. But though the $status_rec has value as '1' it still fails in comparison. Strange thing is var_dumping, i found that though it has proper value, the length is weird & maybe thats why the comparison is failing. Your help is really needed :/
P.S - The DB feild that holds this value is int with length 1