I'm trying to underand how to write code to view images!
Have you ever displayed an image in HTML? If not may want to learn that first. After that you will need to know how to pull data from your database (refer to PradeepKr's post). And then you just have to get the files path and name, from your database, and put it in the <img> tag.
The <img> tag for HTML and the background property in CSS are the only ways you can display images in the browser. There is no other way to view images in the browser. Now technically you could use something like a java applet or flash, but I suspect, if that was what you were using, you wouldn't be asking the question.