Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter get_where
#6

[eluser]n0xie[/eluser]
[quote author="Hanabi" date="1255710455"]Hey noxie,

My controller now includes;
[/quote]
Aah I read too fast, I was under the assumption you were using a model. Since you are calling the database directly from the controller you don't need to return the data.

[quote author="Hanabi" date="1255710455"]
Code:
function files()
{
    $this->load->view('account/files');        
    $owner = $this->auth->get_user();        
    return $this->db->get_where('files', array('owner =' => '$owner'))->result();        
}
[/quote]

Where do you call your view? If your view is 'account/files' change it to this:

Code:
// controller
    $owner = $this->auth->get_user();      
    // we store the output of the query into a data array
    $data['files'] = $this->db->get_where('files', array('owner =' => '$owner'))->result();  
    // we pass the data array to the view
    $this->load->view('account/files',$data);  

// view
    
    // we passed the data array to the view which now gives us access to 'files' where
    // our query result is stored
    <?php foreach($files as $file): ?>

    <div class="section">
        <span>&lt;?=$file->file_name?&gt;</span>    
    </div>

    &lt;?php endforeach; ?&gt;


Messages In This Thread
CodeIgniter get_where - by El Forum - 10-16-2009, 04:42 AM
CodeIgniter get_where - by El Forum - 10-16-2009, 04:47 AM
CodeIgniter get_where - by El Forum - 10-16-2009, 04:56 AM
CodeIgniter get_where - by El Forum - 10-16-2009, 05:18 AM
CodeIgniter get_where - by El Forum - 10-16-2009, 05:27 AM
CodeIgniter get_where - by El Forum - 10-16-2009, 06:07 AM
CodeIgniter get_where - by El Forum - 10-16-2009, 06:15 AM
CodeIgniter get_where - by El Forum - 10-16-2009, 06:28 AM
CodeIgniter get_where - by El Forum - 10-16-2009, 06:37 AM
CodeIgniter get_where - by El Forum - 10-16-2009, 07:44 AM
CodeIgniter get_where - by El Forum - 10-16-2009, 07:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB