Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Location
    wisconsin
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Random link script

    Hi

    I was wondernig if anyone had a script or can direct me to a tutorial so I can make a random link script. I would liek to use php/mysql. Any help would be great. Thanks

  • #2
    New Coder
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    49
    Thanks
    0
    Thanked 3 Times in 3 Posts
    example

    PHP Code:
    <?php

    $link 
    = array(
                
    'http://www.somesite.com',
                
    'http://www.anothersite.net',
                
    'http://mysite.se'
                
    );

    shuffle($link);

    echo 
    "<a href=\"$link[0]\">$link[0]</a>";

    ?>

  • #3
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here:
    <title>Now opening random page..</title>
    <script language="JavaScript">
    var newLocation = new Array();
    var index;
    newLocation[0] = 'http://www.google.com';
    newLocation[1] = 'http://www.allgamesallfree.com/';
    newLocation[2] = 'http://www.yahoo.com';
    newLocation[3] = 'http://www.msn.com';

    index = Math.floor(Math.random()*newLocation.length);
    document.write('<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL='+newLocation[index]+'\">');
    </script>

    No mysql or php required, just copy that into html, add as many links as you want using that format then make a link to the html page on your site and it will bring you to a different page everytime, I do this to make a random game button on my site http://www.allgamesallfree.com so you can see the script at work here: http://www.allgamesallfree.com/RandomGame.html

  • #4
    New Coder
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    49
    Thanks
    0
    Thanked 3 Times in 3 Posts
    He wanted a solution in PHP or mysql, not in javascript. If the user surf around with javascript disabled, your code wont work. Or if the user has javascript enabled but meta-refreshed turned off, the script wont work either.

  • #5
    New to the CF scene
    Join Date
    Nov 2006
    Location
    wisconsin
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the help. I will try it out and see what I can come up with.


  •  

    Posting Permissions

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