Welcome Guest, Not a member yet? Register   Sign In
Variable from Controller not working in Views
#1

[eluser]Kraig[/eluser]
Why is the variable test_var not working in the view like the guide shows? Variable is created at the end.
Controller:
Code:
class Members_area extends CI_Controller {

function index()
{
  $is_logged_in = $this->loggedin->loggedin();
  if(!$is_logged_in)
  {
   $data['main_content'] = 'home';
   $this->load->view('includes/template2', $data);
  }
  else
  {
   $data['main_content'] = 'members_area';
   $this->load->view('includes/template2', $data);
  }
  
  // Grabbing all the files associated with the current user
  $this->load->model("upload_model");
  $q = $this->upload_model->get_files();
  $data['test_var'] = 'Test'; // Trying to use this variable in the views file

}

}

The View File:
Code:
<li>&lt;?php echo $test_var;?&gt;</li>

I get undefined variable as an error


Messages In This Thread
Variable from Controller not working in Views - by El Forum - 08-16-2012, 05:07 PM
Variable from Controller not working in Views - by El Forum - 08-16-2012, 05:15 PM
Variable from Controller not working in Views - by El Forum - 08-16-2012, 05:18 PM
Variable from Controller not working in Views - by El Forum - 08-16-2012, 05:19 PM
Variable from Controller not working in Views - by El Forum - 08-16-2012, 05:45 PM
Variable from Controller not working in Views - by El Forum - 08-16-2012, 06:21 PM



Theme © iAndrew 2016 - Forum software by © MyBB