I get the error shown below when I tried to loop my data/value in my View page.
A PHP Error was encountered Severity: Notice
Message: Undefined variable: tasks
Filename: pages/all.php
Line Number: 2
application/controllers/task.php
public function show() {
$data['tasks'] = $this->Tasks_model->show_task()->result();
$this->load->view('pages/all', $data);
}
application/models/Tasks_model.php
public function show_task() {
return $this->db->get('task');
}
application/views/pages/all
<?php
foreach($tasks as $task) {
?>
<span><?php echo $task->title ?></span>
<?php } ?>
"; print_r($tasks); die(); foreach($tasks as $task) { ?> title ?> `
– G_real Feb 22 '19 at 16:39