CodeIgniter Forums
Message: Undefined variable: data - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Message: Undefined variable: data (/showthread.php?tid=47777)



Message: Undefined variable: data - El Forum - 12-21-2011

[eluser]ibnclaudius[/eluser]
I got Message: Undefined variable: data when running this:

Code:
<?php

class User extends CI_Controller {
function index() {
  $data['page_title'] = "Index";
  $data['body'] = 'Conteudo';
  $this->load->model('Usermodel');
  $this->Usermodel->get_user();
  $this->load->view('index.php', $data);
}
}

?>

Code:
<?php

class Usermodel extends CI_Model {
function get_user() {
  $this->db->get('users');
  return $data['query']->result();
}
}

?>

Code:
<ol>
&lt;?foreach($query as $row) {?&gt;
  <li>&lt;?=$row->name?&gt;</li>
&lt;?}?&gt;
</ol>