By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,339 Members | 1,680 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,339 IT Pros & Developers. It's quick & easy.

random pics

P: n/a
I am new to this so sorry for what is probably a simple question...

I want to have a picture that changes at random each time you go to the page
so that it is different.

Thank you
Jun 27 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
prophet wrote:
I am new to this so sorry for what is probably a simple question...

I want to have a picture that changes at random each time you go to the page
so that it is different.
http://www.google.com/search?query=w...picture&num=50

--
Ed Mullen
http://edmullen.net
Why do we say something is out of whack? What is a whack?
Jun 27 '08 #2

P: n/a
On Apr 13, 7:48 pm, "prophet" <M_Mo...@hotmail.comwrote:
......or do it server-side with a scripting language, perhaps php

function randPicName()
{
$cnt=-1;
$dir = opendir("/var/www/my-site/my-images/my-rands");
while ( $file = readdir($dir))
{
if($file[0] != ".") /// or call some fancier isImage function
{
$cnt++;
$pics[$cnt] = trim($file);
}
}

srand((double)microtime()*1000000);
$randval = rand(2,$cnt);
$pic = $pics[$randval];

/// this is an image name only, so you'd
/// have to prepend a path to make an img src url with it.
return ($pic);
}
Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.