[eluser]erik.brannstrom[/eluser]
No one is going to do this for you, but I'll give you a few pointers.
Move all the database stuff to methods in a model file, preferably using the database class. Once that refactoring is done you are left with the view. Now just create a controller that fetches data via your model and than passes it on to your view file.
It's all thoroughly described in the manual, so please read it. If you've got any more specific questions, feel free to post them here at the forum.