Please see the following functions. They will help you in creating these scripts.
PHP Manual Entries are given.
Directory Functions
opendir ( for opening directory handles)
readdir ( for reading list of files from directory handle)
//No error handling in this code
//$imagedir image directory defined above
//$imagedirurl if different from above
$dir = opendir($imagedir);
while($entry = readdir($dir)){
if($entry!="." || $entry!="..")
echo "<img src='$imagedirurl/$entry'><br>";
}