Hi,
You are lucky, I am just working on a similar script. Here is the solution i made:
That above, is a simple function, that runs through your GAME_DIR (starting from the location of the place where the file with this function is located) and accompanied with particular game subdir, in your case - 'media', and gets all the image file in the dir.
This function does the whole thing, except printing the result in rows. I hope you will get the idea of how to arrange them in a row, or in table!
Hope, this solved some of your problem!

Kaspars
[/PHP]