PHP can loop through the query results and create the <img > list.
But first, you should test it by "hard coding" it with some images.
I'm thinking the marquee isn't going to work very good (but I could be wrong).
Also, it might not work in all browsers ... especially mobile devices.
Test it with hand-coded images and make it work before using PHP / MySQL.
The query part is easy.
EDIT:
Also, are you images stored in a directory, or are they actually
stored in MySQL (Binary BLOB)?