I usually start by creating a non-dynamic version of the page I want to build with only maybe 2-3 images. Then once you have that working you can more easily figure out what you need to repeat and get from your database. Also, once you have that built and can show us what you are trying to do, we can comment more specifically about what to do on what lines of code.