[eluser]jedd[/eluser]
Hi trevor2,
First, you may want to prune your view files by changing things like this:
Code:
// original
if($row->group_id == 0)
{
echo '<td class="tc">No</td>';
}else{
echo '<td class="tc">Yes</td>';
}
... into this ...
Code:
// suggested
echo '<td class="tc">';
echo ($row->group_id) ? "Yes" : "No";
echo '</td>';
Now, I'm not quite sure what you mean about moving view stuff 'into the function' here.
Your controller would, generally, not be making database calls directly - it'd be consulting your relevant model, and the model does the databaase calls, and your controller gets an object or an array sent back.
You're allowed to work with arrays rather than objects, too, of course - the functions exist to go either way, as you've doubtless read in the [url="http://ellislab.com/codeigniter/user-guide/database/queries.html"]Database Queries[/url] page of the user guide. I tend to work with arrays in preference to objects, as they're what I grew up with.
In your second message, it looks like you've moved all your HTML - the domain of your view - into your controller ...? This misses the point of MVC, if it's the case, but certainly having a database query and HTML generation in the one file is way off.