[eluser]Dam1an[/eluser]
Here's something I quickly put together which should do the trick
The key is the join in the model, which joins the user and comments table together
Code:
Model
<?php
function get_comments($story_id) {
$this->db->where('story_id', $story_id);
$this->db->join('users', 'userd.id = comments.user_id');
return $this->db->get('comments');
}
?>
Controller
<?php
function view_story($id) {
$data['story'] = $this->story->get_story($id);
$data['comments'] = $this->comment_model->get_comments($id);
$this->load->view('story_with_comments', $data);
}
?>
View
<?php
echo $story->title;
echo $story->body;
foreach($comments as $comment) {
echo $comment->title;
echo $comment->user_name;
echo $comment->body;
}
?>
Let me know if this is the sort of thing you're after, and if it works (not tested)