Random Image Everytime You Refresh

 
Post new topic   Reply to topic    Aprelium Forum Index -> Tutorials
View previous topic :: View next topic  
Author Message
soulm8sflyff
-


Joined: 18 Feb 2006
Posts: 52

PostPosted: Thu Mar 23, 2006 6:07 am    Post subject: Random Image Everytime You Refresh Reply with quote

Well, this might just be a simple php script and everybody knows about it, but for the sake of those who don't, here it is.

Use your favorite text editor i.e. (Notepad) and copy this:

Code:
<?php

$random = "random.txt";

$fp = file($random);
srand((double)microtime()*1000000);
$rl = $fp[array_rand($fp)];
echo $rl;
?>


Now save that as random.php and drop it in a folder where in the desired images to be randomly shown everytime you refresh are stored.

Meanwhile, open your text editor again and make a path where in the php would find the images i.e. (your root folder/pics), so it would look like this:

Code:
<a href="buyme.php"><img src="/pics/banner1_advert.gif" border="0"></a>
<a href="buyme.php"><img src="/pics/banner2_advert" border="0"></a>


etc. etc. Note: the "<a href=. . . . " will be the link where in your browser would lead you when you click the image, this time, it's a banner advertisement. Now save that as random.txt and drop it again in the folder where the random.php and the images are stored. (the folder: "pics")

Our plan here is to make a random image so that everytime somebody visits your site, he will see a banner with your advertisement there. And when he click it, he will be lead to the page where he can sign up or buy your advertisement. The advantage of a random image is that people wont be bored by the same image always showing up everytime they visit your site. So if you want to advertise, make a lot of cool banners and make them as a rotating image that changes everytime you visit the page where in your banners are put.

Now to put the random image to the page. Choose the best place where to put your banner, i.e. at the top of the page, then just copy this code. It will be the same code for every random image for all the pages you wish to put in. Note: this code is based on the random.php and [ib]random.txt[/b] and the images which are put in the folder "pics" in your root folder. If you wish to put the images, the random.php and the random.txt in a different folder, you should change the path in this code as well as the path in the random.txt. Don't worry about the random.php, as long as you named the .txt file as random.txt, no need to worry.) So here's the code.

Code:
<?php include("http://yourwebsite/pics/random.php"); ?>


Be sure to change "yourwebsite" to the name of your website and be sure to have the correct path as well. Enjoy! Cheers! :D
_________________
"It is better to have only two ideas and one of them is wrong, than to have loads of right ideas but NONE OF THEM ARE YOURS!" - Soul
Back to top View user's profile Send private message Send e-mail Visit poster's website
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Thu Mar 23, 2006 10:07 am    Post subject: Reply with quote

This should have been posted in the tutorials section. Aprelium, can you move it?
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
soulm8sflyff
-


Joined: 18 Feb 2006
Posts: 52

PostPosted: Thu Mar 23, 2006 10:49 am    Post subject: Reply with quote

Sorry . . .
_________________
"It is better to have only two ideas and one of them is wrong, than to have loads of right ideas but NONE OF THEM ARE YOURS!" - Soul
Back to top View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> Tutorials All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group