yes you can't just loop through a bunch of images and output their contents from you script because the browser that requested you php page will think that all of the images you are spitting out are one big jpeg file. it sounds to me like your browser might be downloading all the images and only displaying the first one.
you would need to either alter your script to create a new, big jpeg and place the other jpegs in this new image and then output that (which would be a real coding chore and would tax your server for no reason) or you can just output an HTML page which has multiple IMG tags, each of which refers to your script and supplies it with some identifier that can be used to locate the correct image.
show this to the visitor:
<html>
<body>
<img src="my_php_script.php?q=x">
<img src="my_php_script.php?q=y">
<img src="my_php_script.php?q=z">
</body>
</html>
and then in my_php_script.php, you would put something like this:
$image_key = $_GET['q'];
// code here to read the image from the protected folder and just readfile it like bg says.