[eluser]jk215[/eluser]
Ive been staring at this all morning and I cant figure out why its not working. $entry->listing_url works but $entry->listing_title doesnt. Any help is appreciated.
Here is the error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: stdClass::$listing_title
Filename: listings/index.php
Line Number: 5
Here is my controller:
Code:
<?php
class Listings extends CI_Controller {
public function __construct()
{
parent::__construct();
}
// homepage showing all listings
public function index() {
$this->load->model('Listings_model', 'listings');
$entries['query'] = $this->listings->get_all_entries();
$this->load->view('header');
$this->load->view('listings/index', $entries);
$this->load->view('footer');
}
}
Here is my model:
Code:
<?php
class Listings_model extends CI_Model {
public function __construct()
{
parent::__construct();
}
//Gets all entries in listings table
public function get_all_entries()
{
$this->db->select('listing_url', 'listing_title');
$query = $this->db->get('listings');
if ($query->num_rows() > 0)
{
return $query->result();
}
else
{
return array();
}
}
}
Here is my view:
Code:
<?php foreach ($query as $entry) { ?>
<div class="blog_entry">
<h2><a >listing_url; ?>"><?php echo $entry->listing_title; ?></a></h2>
<span class="metadata">meta</span>
</div>
<?php } ?>