Internet Marketing Requires Knowledge Of The Internet…. Resulting In Desktop-Wealth!

Internet Marketing Resources for Offline and Online Marketing

Php Content Rotator

I found myself helping someone that needed a script the rotated content. In this case he needed a php script to rotate images. I gave him the below information for a php content rotator

Here is an example of the below php rotater script in action.

Hey Dave

I made some minor changes to a script Robert Plank posted on the warrior forum. You can use it to rotate anything but I use it to rotate images.

First use the below code and create a page called images.php

<?php

$hash = floor(time() / (60*60*24));
//srand($hash);

$images = array_map(“trim”, file(“images.txt”));

$image = $images[array_rand($images)];
echo $image;

?>

If you remove the two // before the line strand($hash); the images will rotate on a 24 hour basis, otherwise as it is, it will rotate images on page reload on a random basis.

Remember to upload the above file and save as images.php

Next create a text file called images.txt and add each image on a seperate line. It would look something like this:

<img src=”rightclick.jpg”>
<img src=”horse.jpg”>
<img src=”banner2.jpg”>
<a href=”http://www.spgraphic.com” target=”_blank”><img src=”rightclick.jpg” alt=”graphics”></a>

Note:

On the last line the image is linked to a website and set to open in a new page.

Remember—-> upload and and save the file as images.txt

Next you will want to get an individual image to show on your webpage:

You can use the below php include to bring the image into your webpage. Your pages must have a .php extension to make this work.

<?php require(“images.php”); ?>

OR

You can add a couple lines of code to your .htaccess file which will allow your pages to stay .htm or .html and still process the php code. If you don’t know how to do this you should contact your hosting provider and ask them what code you should use.

ANOTHER WAY

Another way to keep your page extensions as .htm or .html is to use an iframe to bring your images in. You must make sure you change the iframe dimensions to match your image dimensions. For instance if you had a 468 x 60 banner you would want to change to iframe dimensions to 470 x 62…..you might need to experiment to ensure the scroll bar doesn’t show up in the iframe.

PHP INCLUDE

<?php require(“images.php”); ?>

IFRAME

<iframe src=”images.php” width=”300″ height=”100″></iframe>

Don’t be afraid to use php includes or experiment with php code. If you can get it to work it becomes addicting! I’ve learned a lot from Robert Plank, you can check out his blog at PlanksBlog ….it’s packed with good stuff :)

Hope this php content rotator helps you with your client.

You can see how this script rotates content by clicking on that link, there are 3 images that are linked and rotated, the script is configured to rotate random images.

Good luck

Scott

[tags]php content rotator, rotate images, php image rotator[/tags]

Email Question

Donald asks… email problem? how do you send email in yahoo scottparat answers: Send email in yahoo? >you click on Compose or for new Yahoo Beta, click on New then select Email … >type the email add in “To” field (type valid email addresses) >and fill out all the other fields, like CC, BCC, Subject […]

Make Money Online Surveys Question

Sandy asks… Is it possible to make money by taking online surveys? I’m interested in taking online surveys for some extra money on the side of waitressing while I finish getting my degree, but it seems like most of the ones I’ve looked at are a fluke… Are there any substantial online surveys to take […]

Comments

  1. Hey Scott,

    Thanks a bunch for this useful php image rotator script!

    Douglas Wade

  2. scottparat says:

    Glad you like it Douglas…hope you can put the rotator script to good use.

    I create a demo page that rotates ads, images, banners, text and google adsense as a sample…check it out here http://www.spgraphic.com/image_rotator_test/

    Just keep hitting your refresh button on your browser to see how the images rotate, also you can see that I linked the images.

    Take care,

    Scott

  3. I love your script. I have been checking the test page and really like how it changes the whole look of the page with each refresh. Could you please explain in a little more depth how to make the ads and images etc… move to different positions on the page or is it simply a size thing. Im really new to making a website and any help would be wonderful.

Speak Your Mind

*