Assuming that all files in the promos directory are images:
<div class="scrollable" id="browsable">
<div class="items">
<?php
if ($handle = opendir('./promos/')) {
while (false !== ($file = readdir($handle))) {
echo "<div>";
echo "<a href='#'><img src='".$file."' /></a>";
echo "</div>";
}
closedir($handle);
}
?>
</div>
</div>
If, however, there are files in the directory that are not images, you would need to check that before showing it. The while loop would need to change to something like:
while (false !== ($file = readdir($handle))) {
if ((strpos($file, ".jpg")) || (strpos($file, ".gif"))) {
echo "<div>";
echo "<a href='#'><img src='".$file."' /></a>";
echo "</div>";
}
}
JGB146
2010-08-22 03:41:39