in reply to Global program flow
That's a picture album, isn't? Why would you want to generate the pages on demand? Pictures tend to be quite static. Why not generate the entire album once, producing a static set of HTML pages? That would reduce the load on the server, give faster response times for the users, and greatly simplifies the code you have to write.