Submit Your Article Forum Rules

Results 1 to 7 of 7

Thread: Looking for a PHP image rotator script

  1. #1

    Question Looking for a PHP image rotator script

    Can anyone send me a link for a simple, but good PHP script for a image rotator? I have looked at several but none I found work well. I donít have much PHP experience myself. Thanks for all your help!

  2. #2
    Senior Member bj's Avatar
    Join Date
    Apr 2005
    Posts
    1,120

    Re: Looking for a PHP image rotator script

    See it in action here by refreshing:
    Patti

    This isn't the version I used on that particular page, but you'll be able to adjust to taste. I usually use this as a background image rotator, but you might be able to tweak it for what you need.

    Code:
    <!-- begin code provided by createblog.com -->
    <script type='text/javascript'>
    //<![CDATA[
    //
    // random background - jammers
    
    var image = new Array();
    
    // change up the images here
    image[0] = 'images/rotation/01.jpg';
    image[1] = 'images/rotation/02.jpg';
    image[2] = 'images/rotation/03.jpg';
    image[3] = 'images/rotation/04.jpg';
    image[4] = 'images/rotation/05.jpg';
    image[5] = 'images/rotation/06.jpg';
    image[6] = 'images/rotation/07.jpg';
    image[7] = 'images/rotation/08.jpg';
    image[8] = 'images/rotation/09.jpg';
    image[9] = 'images/rotation/10.jpg';
    
    var index = Math.floor(Math.random() * image.length);
    document.write('<style type="text/css"> .topleftimage { background-image: url('+ image[index] +'); background-repeat: no-repeat; background-position: 0 0; border-top: 10px solid #bb7f41;	border-bottom: 10px solid #bb7f41; position: absolute; left: 5%; top: 20px; width: 160px; height: 160px; z-index: 5000;} * html .topleftimage (left: 4%;}</style>');
        	//]]>
    </script>
    <!-- end code provided by createblog.com -->

  3. #3
    WebProWorld MVP
    Join Date
    Aug 2003
    Posts
    1,021

    Re: Looking for a PHP image rotator script

    The PHP I use to show a random image on my home page is:
    Code:
    <img src="images/<?php
    $pics = array('image1.jpg', 'image2.jpg', 'image3.jpg', 'image4.jpg');
    echo $pics[array_rand($pics)];
    ?>" />
    Where the $pics array is just a list of images you wish to show, all the PHP does is to create an img tag within the page.

    To use just name your file something.php, paste in the above and set the image names as required, all images are loaded from the images folder.

    If you want to rotate the background image of a div then the above becomes:
    Code:
    <div style="background-image: url(images/<?php
    $pics = array('image1.jpg', 'image2.jpg', 'image3.jpg', 'image4.jpg');
    echo $pics[array_rand($pics)];
    ?>)" class="picture"></div>

  4. #4

    Re: Looking for a PHP image rotator script

    Thanks guys for all your help, got it working!!!!

  5. #5
    Senior Member
    Join Date
    Aug 2006
    Posts
    395

    Re: Looking for a PHP image rotator script

    aw thanks for the script, i really don't want to use javascript for this as I have in the past - now I can use PHP...

    again THANKS!

  6. #6
    Junior Member
    Join Date
    Dec 2007
    Posts
    2

    Re: Looking for a PHP image rotator script

    I have these that do random and much more, work real well. Background Image Rotator

  7. #7
    Junior Member
    Join Date
    Dec 2007
    Posts
    2

    Re: Looking for a PHP image rotator script

    Meant on that page those link to other, PHP image and page content rotators.

Similar Threads

  1. Replies: 0
    Last Post: 06-07-2008, 02:08 AM
  2. PHP image verification script - WEIRD behaviour! Please HELP
    By kiq in forum Web Programming Discussion Forum
    Replies: 1
    Last Post: 07-04-2006, 08:19 AM
  3. Recommended search engine friendly image gallery script ?
    By funlounge in forum Search Engine Optimization Forum
    Replies: 3
    Last Post: 06-10-2006, 02:08 AM
  4. Rotating image script not working - Anyone able to help?
    By raay in forum Web Programming Discussion Forum
    Replies: 1
    Last Post: 01-09-2006, 02:28 PM
  5. Good open source banner rotator with stats
    By tenaki in forum Web Programming Discussion Forum
    Replies: 1
    Last Post: 08-23-2005, 10:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •