1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need Help: How to rotate links through image?

Discussion in 'General Scripting Chat' started by 1nv1nc1ble, Aug 16, 2011.

  1. 1nv1nc1ble

    1nv1nc1ble Newbie

    Joined:
    Apr 13, 2010
    Messages:
    16
    Likes Received:
    2
    Occupation:
    Aff Marketing
    Location:
    USA
    Ok I didn't know how to properly phrase what I am looking to do.

    Basically I want to have a single image that when clicked it links to one of two rotating links.

    So basically something like this, but with two rotating links:

    Code:
    <a href="hxxp://domain.com" target="_blank">
    <img src="hxxp://domain.com/image.jpg" />
    </a>
    Hopefully this makes sense and thanks in advance for any help.
     
  2. jbrewski

    jbrewski Junior Member

    Joined:
    May 12, 2011
    Messages:
    116
    Likes Received:
    32
    Location:
    USA
    here ya go! you can add more links if need be!

    <?php
    $links = array();

    $links[] = 'http://link1';
    $links[] = 'http://link2';
    $links[] = 'http://link3';

    shuffle($links);

    ?>


    <a href="<?php echo $links[0];?>" target="_blank">
    <img src="hxxp://domain.com/image.jpg" />
    </a>
     
    • Thanks Thanks x 1
  3. 1nv1nc1ble

    1nv1nc1ble Newbie

    Joined:
    Apr 13, 2010
    Messages:
    16
    Likes Received:
    2
    Occupation:
    Aff Marketing
    Location:
    USA
    Jbrewski Thanks a lot man I appreciate the help! :D