WEB How to make a cycling image on a page?

Discussion in 'OT Technology' started by chechen, Feb 9, 2008.

  1. chechen

    chechen Brazilian Jiu Jitsu OT Supporter

    Joined:
    Sep 29, 2003
    Messages:
    23,881
    Likes Received:
    0
    Location:
    Irvine, CA
    http://www.lacie.com/us/index.htm

    check out this website and refresh a couple times. You notice that the large image changes randomly each time to a different one. How is this done?
     
  2. 2ofdem

    2ofdem OT Supporter

    Joined:
    Jun 17, 2003
    Messages:
    114,854
    Likes Received:
    8
    Location:
    aus.vic.mel
    you could do it with php quite easily
     
  3. 2ofdem

    2ofdem OT Supporter

    Joined:
    Jun 17, 2003
    Messages:
    114,854
    Likes Received:
    8
    Location:
    aus.vic.mel
    <?php

    $pic = rand(1, 3);

    if ($pic == 1) {
    echo '<img src="pic1.jpg" />';
    } elseif ($pic == 2) {
    echo '<img src="pic2.jpg" />';
    } elseif ($pic == 3) {
    echo '<img src="pic3.jpg" />';
    }

    ?>

    There ya go thatll do it

    want to add more then 3
    add this to the end

    elseif ($pic == 3) {
    echo '<img src="pic3.jpg" />';
    }

    and change the rand(1, number here);
     
  4. JoeyJoJoJuniorShabadoo

    JoeyJoJoJuniorShabadoo Live Free or Die

    Joined:
    Nov 9, 2004
    Messages:
    4,347
    Likes Received:
    0
    Location:
    http://www.stogietime.com
    bingo
     
  5. ROFLCORE

    ROFLCORE Guest

    I have something that will do it with php, but you don't have to tell which images to rotate. It will automatically rotate any and all images within the same directory of the file itself. Pwn
     
  6. nashstradamus

    nashstradamus New Member

    Joined:
    Nov 2, 2003
    Messages:
    899
    Likes Received:
    0
    Location:
    East Coast, USA
    ive done something exactly like that with javascript
    real easy. i can pm u code if u want. u just had to make all the images the same size and drop them in your images folder with a specific name
     
  7. chechen

    chechen Brazilian Jiu Jitsu OT Supporter

    Joined:
    Sep 29, 2003
    Messages:
    23,881
    Likes Received:
    0
    Location:
    Irvine, CA
    you guys are very helpful people :bowdown:

    i haven't tried out the code, but I am very impressed with your response time :)
     
  8. 2ofdem

    2ofdem OT Supporter

    Joined:
    Jun 17, 2003
    Messages:
    114,854
    Likes Received:
    8
    Location:
    aus.vic.mel
    :wiggle: chuck that code where the IMG tag normally is, if it doesnt work gimme a yell.
     
  9. Necromancer

    Necromancer Guest

  10. Necromancer

    Necromancer Guest

    I PM'd ya.
     

Share This Page