php random pic
Posted: Mon Mar 07, 2011 4:01 pm
i have got this script which displays all folders within a folder but what i want to do now is get it to display a random picture for each of the folders that it is showing in the grid.
script
script
Code: Select all
<form name="Gallery" method="post">
<?php
$path = "gallery_files/gallery/";
$dir_handle = @opendir($path) or die("Unable to open folder");
echo "<table cellspacing='15'>";
echo "<tr>";
while (false !== ($folder = readdir($dir_handle))) {
if($folder == "index.php")
continue;
if($folder == ".")
continue;
if($folder == "..")
continue;
echo ($x % 6 == 0) ? "</tr><tr>" : "";
echo "<td><a href='pictures/?folder=$folder'><img src='path/to/random/image' style='height:auto;width:110px;' alt='$folder'></a><br /><a href='pictures/?folder=$folder'>$folder</a></td>";
$x++;
}
echo "</tr>";
echo "</table>";
closedir($dir_handle);
?>
</form>