[eluser]ThanksBrah[/eluser]
hello. new to codeigniter and I'm running into a query issue.
I get this message when running a query : Message: Undefined variable: results, basically saying that my query isn't returning a result.
Now, I've tested the query by building a basic php page where I connected to the DB and ran the query and got results.
here's my model:
Code:
[color=blue]<?php
class legacy_model extends CI_Model {
public function getDB()
{
$query = $this->db->query("SELECT * FROM synopsis_header");
return $query->result();
}
}[/color]
here's my controller:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class legacy_controller extends CI_Controller {
Code:
[color=blue]
public function index()
{
$this->legacy_view();
}
public function legacy_view()
{
$this->load->view("legacy_view");
}
public function getValues() {
$this->load->model("legacy_model");
$data['results'] = $this->legacy_model->getDB();
$this->load->view("legacy_view",$data);
}
}[/color]
and here's my view
Code:
[color=blue]<div id="container">
<h1>What works in character education!</h1>
<div id="body">
<?php
print_r($results);
?>
</div>[/color]
I cannot for the life of me see what the issue is. maybe someone can see what's going on.
Thanks in advance