A javascript that inserts a random image with its corresponding link. I need this for a website project I'm doing. But I'm keeping my eye out for a PHP script that does this because javascript tends to take a bit longer to load.
I’ll try it out tonight! I’m at an internet cafe now. I’m going around (or at least I was going to until it started raining) to see some buddhist temples with a Spanish friend.
TimYang.com ::: The Geek Blog
BlogThis!
Thursday December 09
Random image link
A javascript that inserts a random image with its corresponding link. I need this for a website project I'm doing. But I'm keeping my eye out for a PHP script that does this because javascript tends to take a bit longer to load.
http://javascriptkit.com/script/cut144.shtml
Comments
Will this do ya?
$images = array(
“apache2.gif”,
“doom3_box.jpg”,
“dunstans_blog.jpg”
);
$urls = array(
“http://www.apache.org”,
“http://www.doom3.com”,
“http://1976design.com/blog/”
);
$image = rand(0, sizeof($images)-1);
echo “<a href=’{$urls[$image]}’><img src=’http://richardathome.no-ip.com/img/{$images[$image]}’ alt=’{$urls[$image]}’/></a>”;
Don’t forget to chage the location of your image directory :-)
working example here: http://richardathome.no-ip.com/examples/random_image_link/
Thanks Richard!
I’ll try it out tonight! I’m at an internet cafe now. I’m going around (or at least I was going to until it started raining) to see some buddhist temples with a Spanish friend.