Now I am editing a working project with some experience in PHP.
I am a little basic, but I know only a little about MVC and Code-Igniter, therefore, I will encounter some problems.
My first problem is that I am trying to populate a drop down list from a controller.
The view is called overview_screen.php, and the controller is called overview.php.
In the controller, I have a function:
private function getYears()
{
return array('Test1', 'Test2', 'Test3', 'Test4');
}
which I set in the $ year index:
function index()
{
$years = $this->getYears();
$menu = $this->getMenu();
}
when I do var_dump in the $ menu, it shows the menu as it should be shown, but when I do var_dump in $ years, it says:
PHP Error was encountered
Severity: Notice
Message: Undefined variable: years
Filename: views/overview_screen.php
Line Number: 92
Does anyone know why this is happening / not working?
[edit]
Added information:
<?php
print_r(CI_session::userdata('docent_id'));
if (!$this->session->userdata('docent_id')) {
header ('Location: /bpv-registratie/welcome.html');
}
?>
<html>
<head>
<title>Registratie Systeem</title>
</head>
<body>
<div id="topmenu">
<a href="/registratie/" class="button">Start</a>
<a href="/registratie/welcome/logout.html" class="button">Log uit</a>
</div>
<div id="topmenuright">
<?php var_dump($years); ?>
<select>
<?php foreach ($years as $row):?>
<option><?=$row?></option>
<?php endforeach;?>
</select>
</div>
<div id="menu">
{menu}
</div>
<div id="content">
{content}
</div>
</body>
</html>