[eluser]patsm[/eluser]
I'm new to Code Igniter and I've read all through the TOC and even have an existing application to use as a guide. However, I don't understand how to access a value from the database in one of my views.
This is part of my controller
Code:
class classifieds extends Controller {
function classifieds() {
parent::Controller();
$this->load->model('mdl_billingplan');
$this->load->model('mdl_category');
$this->load->model('mdl_item');
$this->load->model('mdl_subcategory');
$this->load->model('mdl_transaction');
$this->load->model('mdl_user');
$this->load->model('mdl_settings');
$this->load->model('mdl_common');
}
}
function index() {
$data['header_menu'] = 1;
// get the categories
$data['categories'] = $this->mdl_common->get_category_array();
// get featured and most recent ads
$data['featured_ads'] = $this->mdl_common->get_featured_ads();
$data['recent_ads'] = $this->mdl_common->get_recent_ads();
$data['features'] = $this->mdl_common->getFeatures();
// generate and display the view
$page = $this->load->view('view.header.php',$data,true);
$page .= $this->load->view('view.sidebar.php',$data,true);
$page .= $this->load->view('view.index.php',$data,true);
$page .= $this->load->view('view.footer.php',null,true);
echo $page;
}
This is the getFeatures function in the mdl_common Model as referenced in the Controller
Code:
function getFeatures() {
$this->db->where("id = 1");
$query = $this->db->get("features");
$features = $query->row();
return ($features);
}
The table I am accessing in my mySQL database is called features. I have two fields in that table called leftTopNav and leftBotNav.
I would like to access the value of leftTopNav in my view in the file 'view.sidebar.php' (this is referenced in my controller and displays but I don't understand how to get the values.
I've tried $features['leftTopNav'], I've tried $features[0], I've tried $leftTopNav along with all sorts of other things. I just don't get it!!!
I know this is such a simple thing, but it has me stuck. Can someone tell me how to access this data in the form of a variable?
Thanks!