[eluser]Unknown[/eluser]
Hello CI Forums. I am fairly new to CodeIgniter, and recently decided to switch over to it to make developing in PHP easier.
For the CI site I'm developing right now, I have one Controller, bachmax.php. It's supposed to, and from the looks of it, successfully loads the Model Data and the View home (data array passed to it).
Code:
<?php
class Bachmax extends CI_Controller
{
function index()
{
$this->load->model('Data', '', TRUE);
$data['notice_title'] = $this->Data->notice_title();
$data['notice_body'] = $this->Data->notice_body();
$this->load->view('home', $data);
}
}
?>
There's also the Model, data.php. The functions are supposed to pull a title and body of a notice IF they exist, and pass it back to the Controller.
Code:
<?php
class Data extends CI_Model
{
function __construct()
{
parent::__construct();
}
function notice_title()
{
$this->db->select('title');
$query = $this->db->get('notice');
if($query->num_rows() > 0)
{
$notice_title = $query->result();
return $notice_title;
}
else
return 0;
}
function notice_body()
{
$this->db->select('body');
$query = $this->db->get('notice');
if($query->num_rows() > 0)
{
$notice_body = $query->result();
return $notice_body;
}
else
return 0;
}
}
?>
Finally, here's the snippet of the notice box from the View.
Code:
<?php if($notice_title && $notice_body):?>
<div id="important">
<div id="importanthead"><h1><?php echo$notice_title; ?></h1></div>
<div id="importantbody">
<p><?php echo $notice_body; ?></p>
</div>
</div>
<?php endif; ?>
The database is queried, and the code works in a sense that it returns something if it's there. But all it returns - literally - is "Array."
I've checked through the User Guide for the past couple of hours to see if anything was incorrect, but I can't find anything that solves the problem.
Any help would be greatly appreciated. Thanks!