Reputation: 489
I'm getting an error Undefined variable: query. I've been searching through the codeigniter forums and here for a solution but nothing seemed to work. If you can find what I'm doing wrong here I would greatly appreciate it.
Message: Undefined variable: query Filename: views/display.php Line Number: 3
Controller
function index() {
$this->load->model('mdl_tasks');
$data['query'] = $this->mdl_tasks->get('priority');
$this->load->view('display');
}
}
Model
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Mdl_tasks extends CI_Model {
function __construct()
{
// Call the Model constructor
parent::__construct();
}
function get($order_by) {
$this->db->order_by($order_by);
$query = $this->db->get('tasks');
return $query;
}
}
View
<h1>Your tasks</h1>
<?php
foreach ($query->result() as $row) {
echo "<h2>".$row->title."</h2";
}
?>
Upvotes: 0
Views: 1406