[snip]
If you actually want to load a different image each time, start with
php.net/rand Perhaps the image names could be integer based, or you
could
oad the image paths into an array and use rand to select based on a
numeric
key. Or you could store the image paths in a mysql database and use
mysql's
RAND to select an image path for display.
The possibilities are endless, but seeing this is a php list I won't
mention
J...s....t :-)
[/snip]
Script That Shall Not Be Named!
Selecting a random image from a directory using only PHP is not
tremendously difficult;
/*random picture picker*/
define ("ALBUM", "the/place/where/pictures/are/kept");
$albumOpen = opendir(ALBUM);
while(FALSE !== ($pic = readdir($albumOpen))){
$picParts = explode(".", $pic);
if("jpg" === $picParts[1]){
$arrDisplayPic[] = $pic;
}
}
closedir($albumOpen);
$randImgIndex = rand(0, (count($arrDisplayPic)-1));
/* test for the image size and reformat if needed,
* in this case one 350 px wide
*/
$imgInfo = getimagesize(ALBUM.$arrDisplayPic[$randImgIndex]);
if("350" <= $imgInfo[0]){
echo "<img src=\"" . ALBUM.$arrDisplayPic[$randImgIndex] . "\"
width=\"350\" align=\"right\" hspace=\"10\" vspace=\"10\">";
} else {
echo "<img src=\"" . ALBUM.$arrDisplayPic[$randImgIndex] . "\"
align=\"right\" hspace=\"10\" vspace=\"10\">";
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php