[eluser]leonards[/eluser]
You could just do it directly into your view file too but the important thing about MVC structure is to do all the "mechanism" in the controller and all the databases related communications in the model.
So, to push the MVC as far as you can you could
1. Put the $query = $this->db->query in a model
2. Do the loop in the controller and pass it to the view.
2a. ** Maybe some data validation stuff here before passing to view**
3. The view receive all cleaned datas and parse it to screen.