I got an error like this :
A PHP Error was encountered Severity: Notice
Message: Undefined variable: tasks
controller
public function show() { $data['tasks'] = array(); $data['tasks'] = $this->Tasks_model->show_task()->result(); $this->load->view('pages/all', $data); } view
<?php if( isset($tasks) && ( is_array($tasks) && count($tasks)>0 ) ) { //echo"<pre>"; print_r($tasks); die(); for($i=0;$i<count($tasks);$i++) { ?> <span><?php echo $task[0]['job']; ?></span><br /> <?php } ?> <?php } else { ?> <span>No tasks records found.</span> <?php } ?> Model
public function show_task() { return $this->db->get('task'); } what's wrong with my code?