You need to add some code to indicate which image, by id, to display, then you need a second PHP file to loop through the ids and display the images.
You might want to leave the images in the file system and store an id, name, and caption in the database. Databases can't search images for content, so they don't add much value as a storage mechanism.