I just got started with CodeIgniter and am wondering will it slow things down if I put code like this in a loop.
$data[\'title\'] = \'the title\';
$d
Think about moving loop from controller to the view file (at controller you must prepare all data before load view file). You will have only one call for loading view file, and in the view file you can print out info in the loop cycle as you want.
Loop in the view.
<div>
<?php foreach ($this->user_model->get_users() as $users): ?>
<p><?php echo $user->first_name;?></p>
<p><?php echo $user->last_name;?></p>
<?php endforeach; ?>
</div>
This sample directly gets data from the model which has been many times been discussed in the codeigniter forums.
I would not recommend calling your model from your view. This is not best practice when trying to keep to MVC framework standards. Call the model from your controller and pass the "users" array into the view as part of $data. Now you access the $users array just as a variable in the view. Similar to what you had, but this gets the access to the model back into the controller.
Controller
$data['title'] = 'the title';
$data['content'] = 'blah blah blah';
$data['users'] = $this->user_model->get_users();
$this->load->view('result', $data);
View
<?php foreach ($users as $user) {
echo '<p>' . $user->first_name . '</p>';
echo '<p>' . $user->last_name . '</p>';
}?>