Welcome Guest, Not a member yet? Register   Sign In
Displaying results from a Left Join
#1

[eluser]Chris Williams[/eluser]
I'm trying to get this query to display.

Code:
$this->db->select('*');
$this->db->from('z_customer_entity');
$this->db->join('z_checklist_items', 'table_a.id = table_b.table_a_id', 'left');
        
$query = $this->db->get();
        
$this->load->view('reports_view', $query);

I'm using this in the view file:
Code:
<?php foreach ($query->result() as $row): ?>

    <li>&lt;?=$row->entity_id?&gt; | &lt;?=$row->checklist_item_id?&gt;</li>

&lt;?php endforeach; ?&gt;

But I'm getting this error: Message: Undefined variable: query

What am I missing?
#2

[eluser]gtech[/eluser]
try:
Code:
$this->load->view('reports_view', array('query'=>$query));

load view expects an associative array and the keys get broken down into variables.
#3

[eluser]Chris Williams[/eluser]
That worked great! Thanks!
#4

[eluser]gtech[/eluser]
no probs! quite a lot of people get stuck or miss an obvious mistake when passing parameters to the view.




Theme © iAndrew 2016 - Forum software by © MyBB