Code Library
Home Submit Free Hosting Link To Us Contacts

PHP Random picture from folder

PHP Random picture from folder PHP PHP Random picture from folder Download (.zip)



<?
$dir = "Summer";

function smqtai($dir, $sbor, $rez) {
        $handle = opendir($dir);
        while($file = readdir($handle)) {
                  if ($file == "." || $file == ".." || $file == "Thumbs.db" || is_dir("$dir/$file")) { }
                  else {
                          $sbor = $sbor+1;
                          if ($sbor == $rez) { echo "<IMG SRC='$dir/$file'>"; }
                  }
        }
        return $sbor;
        closedir($handle);
}
if (is_dir($dir)) {
        $tot = smqtai($dir, "0", "");
        $nom = rand(1,$tot);
        $tot = smqtai($dir, "0", "$nom");
}
?>






Tatet