You cannot display more than one image at a time like this.
HTML works with one image per IMG tag.
This is exactly why you should not put the image data itself in a database, because if you want to display 10 images you will need 10 IMG tags that start 10 scripts that open 10 connections to the database and run 10 queries.
If such a page is requested by ten users ad the same time, your database is swamped with 100 queries all demanding many kilobytes of image data. If your database is not up to the job, it will die (especially crappy old mysql which has never liked many concurrent queries)
Instead, store the image data as a normal file and store only the location of that file in the database. THen you can put the location of the file into the IMG tag and the webserver can open it and process it, which is many time faster than reading the data from the database.