CodeIgniter Forums
Newbie with a query questions. Results not getting passed to view. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Newbie with a query questions. Results not getting passed to view. (/thread-33798.html)



Newbie with a query questions. Results not getting passed to view. - El Forum - 09-08-2010

[eluser]ThanksBrah[/eluser]
Hola.

As stated, the results are not getting passed to my view.

here's what I have:

Controller:

Code:
$this->load->model('membership_model');
        
        $results= $this->membership_model->search();
        
        $data['organizations'] = $results['rows'];
        $data['num_results'] = $results['num_rows'];
            
        $this->load->view('members_area', $data);


Model:
Code:
function search()
    
    {
        //results
        $query = $this->db->select('orgID, FLName, eGRANT_ID')
                                ->from('organizations');
        
        $results['rows'] = $query->get()->result();
        
        
    
            
    }

View:

Code:
<?php var_dump($organizations); ?>
    
    <tbody>
    &lt;?php foreach($organizations as $org): ?&gt;
    
    <tr>
      <td>&lt;?php $org->orgID; ?&gt;</td>
      <td>&lt;?php $org->FLName; ?&gt;</td>
      <td>&lt;?php $org->eGrant_ID;?&gt;</td>
    </tr>
    
    &lt;?php endforeach; ?&gt;
    
    </tbody>

I added var_dump() and the parameter '$organizations' is null giving me a Invalid argument supplied for foreach() error.

Can anyone see what I'm doing wrong?

Thanks


Newbie with a query questions. Results not getting passed to view. - El Forum - 09-08-2010

[eluser]slowgary[/eluser]
Your model's search() function doesn't return any data Smile