[eluser]tonanbarbarian[/eluser]
In this case because the code is really only ever displayed in a view then I would create a helper or plugin.
Having said that because you want the data to come from the database then what i do in the helpers is use get_instance to get an instance of the CI, then I would load a library and call a method in the library to get the data.
The reason I prefer to put this into a library is because
1. it is accessing the database,
2. i do not like complex code in my helpers
Yes it means I more code file having to be parsed and processed but I prefer to move things like this into libraries.
It means that most of my complex code is either in controllers, models or libraries
Where possible I keep my helpers and plugins as wrappers for library methods
but that is just me