Hello, To make things simple, I need a small modification to my script, that shows a few random thumbnails like on this index page. Here is an example for it. Anyone got any ideas how I can do that? Thanks in advance...
it would be rather easy if you're using a MYSQL database, just append "ORDER BY RAND()" to your query. If you're reading the pictures from a directory you just read all the files into an array and use $image = $array[rand(0, count($array)];
Hey thanks for that fast reply. Would I have to include that in a file or write a new one? Also, my script opens image with this: <# UPLOAD_PATH #> and <# FILENAME #> Not sure if thats from Dir or Database, I think Database. I'm very inexperienced when it comes down to php and mysql
You can try this $dir = "/file/dir/here/"; $http = "http://www.domain.com/file/dir/here/"; $images = array(); $images_display = 5; $dh = opendir(w$dir); while (false !== ($file = readdir($$dh)) { if (strpos($file, ".jpg") != FALSE || strpos($file, ".gif") != FALSE || trpos($file, ".png") != FALSE) $images[] = $file; } } closedir($handle); $echoStr = ""; for($i=0;$i < $image_display; $i++) { $ran = rand(0, count($images)); $file = $http.$images[$ran]; $echoStr = "<img src='$file'/>"; } echo $echoStr; PHP: