View Full Version : Using PHP for random image on HOME PAGE
AntoineArt
September 6th, 2006, 09:35 PM
After many months of wondering how and even after making a few failed attempts, I have finally learned how to load a random image using PHP -Thanks to kirupa's excellent article (http://www.kirupa.com/web/random_image.php) *doing my happy dance!* :chinaman:
Here it is exactly as I wanted: http://www.antoineart.com/index.php (first image)
BUT NOW: How do I get that onto my home page (AntoineArt.com)? In order for that page to display as my home page I need to name it index.html... but if I change the .php to .html the code does not work anymore :diss:
Advice would be appreciated!
hl
September 6th, 2006, 11:29 PM
It doesn't have to be index.html. index.php can be your home page... just delete the index.html and voila.
mBm
September 7th, 2006, 03:22 PM
you can use .htaccess file.
AddHandler application/x-httpd-php .html .htm
use above code in .htaccess file. then you can use html files as php file.
hl
September 7th, 2006, 04:44 PM
^ That too, but its extremely useless.
AntoineArt
September 11th, 2006, 05:07 PM
Excellent, thank you! Can't wait to go and give it a shot.
AntoineArt
September 12th, 2006, 11:41 AM
IT WORKED! you are the best (-:
phlegma
February 4th, 2008, 01:48 AM
can you link these random images?
actionAction
February 4th, 2008, 11:40 AM
can you link these random images?
Yes, using an associated array. The link array index positions MUST correspond to the image files array index position.
$file_array = array
('http://www.kirupa.com/me/footer/footer_home.gif',
'http://www.kirupa.com/me/footer/footer_mit.gif',
'http://www.kirupa.com/me/footer/footer_music.gif',
'http://www.kirupa.com/me/footer/footer_music2.gif',
'http://www.kirupa.com/me/footer/footer_tv.gif',
'http://www.kirupa.com/me/footer/footer_orange.gif',
'http://www.kirupa.com/me/footer/footer_game.gif');
ADD THIS WITH YOUR LINKS
$link_array = array
{ 'http://www.kirupa.com/forum/link1.php',
'http://www.kirupa.com/forum/link2.php',
'http://www.kirupa.com/forum/link3.php',
'http://www.kirupa.com/forum/link4.php',
'http://www.kirupa.com/forum/link5.php',
'http://www.kirupa.com/forum/link1.php',
'http://www.kirupa.com/forum/link1.php',};
Then directly under this line:
$file = "$file_array[$random]";
type this:
$link = "$link_array[$random]";
Then you would change this:
print("<img src=$file></a>");
TO
print("<a href=$link><img src=$file /></a>");
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.