PHP Function to select and display all the records stored under the column "clubName", from the table 'clubs'. The foreach statement ($club) returns an undefined variable error. What have I missed?
Controller:
<?php defined('SYSPATH') OR die('No direct access allowed.');
class Club_Controller extends Template_Controller {
public $template = 'kohana/template';
public function index()
{
$this->template->title = 'All clubs';
$this->template->content = new View('allclubs');
$clubs = ORM::factory('club')->find_all();
$this->template->content->club = $clubs;
}
}
?>
View:
<?php defined('SYSPATH') OR die('No direct access allowed.'); ?>
<div class="box">
<b><?php echo html::anchor('entry/form', 'add entry') ?></b><br>
<table cellpadding="10">
<?php foreach($clubs as $club): ?>
<tr>
<td align="left">
<?php echo html::anchor('entry/form/'.$club->id, 'edit') ?>
<?php echo html::anchor('entry/delete/'.$club->id, 'delete',
array('onclick'=>'return confirm("Are you realy realy want to do it?")')) ?>
</td>
<td align="left">
<?php echo $club->clubName ?>
</td>
</tr>
<?php endforeach ?>
</table>
</div>