Welcome Guest, Not a member yet? Register   Sign In
Messing Arround With CI
#2

[eluser]garymardell[/eluser]
You are returning the results as an array but using it like a object.

Use this:

Code:
function getSettings(){
     $q = $this->db->get('tbl_settings');
     return $q->result();
    
    }

That should make your code work as it is.
You should also note that i believe it good practice to return the whole get() object back if you are getting results.

Code:
function getSettings(){
     return $this->db->get('tbl_settings');    
    }

Code:
function index()
     {
      $this->load->model('data_news');
      $this->load->model('data_overall');

          $data['news'] = $this->data_news->getNews();
          $data['s'] = $this->data_overall->getSettings();
        
      $this->load->view('index', $data);
     }

then in the view you can do:

Code:
<? if($s->num_rows() > 0): ?>
    <? foreach($s->result() as $row): ?>
        <title><?=$row->f_sitetitle;?></title>
    <? endforeach; ?>
<? endif; ?>

This way your view has access to the num rows function which allows you to display items such as "you do not have any posts" or else display the posts.


Messages In This Thread
Messing Arround With CI - by El Forum - 08-11-2009, 05:05 AM
Messing Arround With CI - by El Forum - 08-11-2009, 05:18 AM
Messing Arround With CI - by El Forum - 08-11-2009, 05:24 AM
Messing Arround With CI - by El Forum - 08-11-2009, 05:37 AM
Messing Arround With CI - by El Forum - 08-11-2009, 05:50 AM
Messing Arround With CI - by El Forum - 08-11-2009, 05:56 AM
Messing Arround With CI - by El Forum - 08-11-2009, 06:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB