[eluser]tonanbarbarian[/eluser]
in fact i would say you should NOT do any loop processing in the controller IN THIS CASE (in some very specific cases it is ok)
in this example you are simply displaying the values from the data in the view.
so if you were to loop through that data in the controller what would you be doing? probably just creating a string and putting paragraph tags around each item and adding it to the string. you would then send the string to the view and it would echo it out.
Why should you NOT do that in the controller.
simple. MVC is about code separation. You are separating business logic (Controller) from data logic (Model) and presentation logic (View)
So any time you need to present something to the user you should do that in the view.
The idea is that ultimately you can assign the responsibility for each layer to a different specialist.
So you can have a developer doing the business logic (controller), a database designer doing the data logic (model) and a front end designer doing the presentation logic (view). Each person only needs to understand how their part of the process works and they only work on their own files.
So if you put presentation code into the controller the view has no control over it.
Really there are probably very few cases in the controller where you should loop through any data returned by the model.
In some cases you might want the controller to exclude some results returned from the model, but ideally the model should already have excluded the results
The controller determines what data is needed by the view
the model can loop through the data is is generating of course, but it should NOT format the data in any meaningful way.
it might truncate some data that is too long, or concatenate multiple fields, but it should not style or otherwise format the data it generates
this does mean more code in the view, but that is how MVC should work. each controller, model and view should be able to be coded and treated separately and in isolation
so the controller should not know how the model is gathering data or how the view will present it, it just knows what data it needs for what action (method)
the model should not need to know why data is needed or how it is going to be presented, it should just return the data that is asked for
and the view should not care how the data was gathered, it just knows that it has certain data it expects and how it will format it.