...

View Full Version : Random link script



simacaj
11-11-2006, 02:35 AM
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

Nicklas
11-11-2006, 02:45 AM
example


<?php

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

shuffle($link);

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

?>

ab9003
11-11-2006, 02:57 AM
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

Nicklas
11-11-2006, 03:52 AM
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.

simacaj
11-11-2006, 04:18 AM
Thanks for the help. I will try it out and see what I can come up with.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum