Looking at frameworks I came across Codeigniter. I was wondering what the proper process would be to build the html output for results from the db before passing it to the view. Meaning I create a model to fetch rows from the db, load the model in the controller, before passing the results to the view I want to build the view using the results instead of looping through the results and displaying it in the view itself. If I were to do that would I create a private function in the controller to do that? Or would I do that in the model or should I just do that in the view?
I just feel this would be cleaner to do than write all the code in the view to display the results so if there were changes to the display of the results or display it on another page I can just re-use the display function instead of copying and pasting the code from the view.
The view is the information that is being presented to a user. That’s where you should be looping through your results.
Have a look at http://codeigniter.com/user_guide/overview/mvc.html for more an overview of what the models, controllers and views are responsible for.