12-11-2008, 09:34 PM
[eluser]Brad Morse[/eluser]
This is what I came up with with a little digging thru the forums:
Please let me know if there is a better way to do this:
This is what I came up with with a little digging thru the forums:
Please let me know if there is a better way to do this:
Code:
Controller
<?php
function index() {
$data['title'] = "My Blog Title";
$data['heading'] = "My Blog Heading";
//$data['query'] = $this->db->get('entries');
$this->db->select('*');
$this->db->from('entries');
$this->db->join('authors', 'authors.id = entries.author_id');
$data['query'] = $this->db->get();
$this->load->view('blog_view', $data);
}
?>
View
<?php foreach($query->result() as $row): ?>
<h2><?=$row->title?></h2>
<?php
$body_text = $row->body;
print character_limiter($body_text, 210);
?>
<p>Author: <?=$row->first_name.' '.$row->last_name?></p>
<p><?=anchor('blog/more/'.$row->id, 'Read on');?></p>
<p><?=anchor('blog/comments/'.$row->id, 'Comments');?></p>
<hr>
<?php endforeach; ?>