I'd like a simple rotating script

Discussion in 'HTML & Website Design' started by Kyle H., Feb 15, 2007.

  1. #1
    I would like a simple rotating script. This will probably be the worlds simplest website yet I'm not sure how to go about it. This is what I envision:

    Blank white site with a simple script that shows a different 125x125 image above the fold every 2 seconds, and I can hyper link to each image.

    So you would go to mydomain.com and the script would start, image 1 and link to x.com , 2 seconds, image 2 plus link to y.com pops up and replaces image 1, image 3 pops up....etc.

    Can someone tell me what code I Need to generate the image and hyperlink every 2 seconds?
     
    Kyle H., Feb 15, 2007 IP
  2. karan265

    karan265 Active Member

    Messages:
    1,691
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    90
    #2
    Yes, pretty easy. Follow these steps :-

    1) Create a file "rotator.php" with the following code :-

    <?php

    $fcontents = join ('', file ('rotate.txt'));
    $s_con = split("~",$fcontents);

    $banner_no = rand(0,(count($s_con)-1));
    echo $s_con[$banner_no];
    ?>

    2) Create a txt file "rotate.txt" with the following code :-

    banner1
    ~
    banner2
    ~
    banner3
    ~
    banner4

    and so on... Replace banner1, banner2, banner3, banner4 with your desired code.

    3) Open the php file where you need to rotate your banner and insert the following code exactly where you need it :-

    include 'rotator.php'

    Credit goes to original script writer...

    And you're done. :)

    Hope it helps
     
    karan265, Feb 15, 2007 IP
    Kyle H. likes this.
  3. Kyle H.

    Kyle H. Active Member

    Messages:
    839
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    78
    #3
    Thanks Karan :)

    So do I have to make an index.php?

    This is only a 1 page website.
     
    Kyle H., Feb 15, 2007 IP
  4. Kyle H.

    Kyle H. Active Member

    Messages:
    839
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    78
    #4
    Kyle H., Feb 15, 2007 IP
  5. karan265

    karan265 Active Member

    Messages:
    1,691
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    90
    #5
    You have to make an index.php. That code wont work in .html files. Its ONLY for PHP. :)
     
    karan265, Feb 15, 2007 IP