Welcome Guest, Not a member yet? Register   Sign In
Why I can't use .= on controller
#1

[eluser]Marcus Marden[/eluser]
Hi,

I want to use .= in controller and send it to view but it is getting error.

Code:
// controller
$data['title'] = "Test";

...
foreach($query->result() as $row)
{
$list['items'] = $this->sql_model->list($row->id);
$data['listing'] .= $this->load->view('list_view', $list, TRUE);
}
$this->load->view('template_view', $data);

Code:
// view
<?php echo $title; ?>
Content List:

<?php echo $listing; ?>

$data['listing'] line showing error, how can I fix it?
#2

[eluser]Aken[/eluser]
You need to define it as an empty string before using .= or it'll throw a notice error. Just do this before your foreach loop:
Code:
$data['listing'] = '';




Theme © iAndrew 2016 - Forum software by © MyBB