Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-11-2006, 02:35 AM   PM User | #1
simacaj
New to the CF scene

 
Join Date: Nov 2006
Location: wisconsin
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
simacaj is an unknown quantity at this point
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
simacaj is offline   Reply With Quote
Old 11-11-2006, 02:45 AM   PM User | #2
Nicklas
New Coder

 
Join Date: Jun 2006
Location: Sweden
Posts: 49
Thanks: 0
Thanked 3 Times in 3 Posts
Nicklas is on a distinguished road
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>";

?>
Nicklas is offline   Reply With Quote
Old 11-11-2006, 02:57 AM   PM User | #3
ab9003
New to the CF scene

 
Join Date: Nov 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
ab9003 is an unknown quantity at this point
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
ab9003 is offline   Reply With Quote
Old 11-11-2006, 03:52 AM   PM User | #4
Nicklas
New Coder

 
Join Date: Jun 2006
Location: Sweden
Posts: 49
Thanks: 0
Thanked 3 Times in 3 Posts
Nicklas is on a distinguished road
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.
Nicklas is offline   Reply With Quote
Old 11-11-2006, 04:18 AM   PM User | #5
simacaj
New to the CF scene

 
Join Date: Nov 2006
Location: wisconsin
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
simacaj is an unknown quantity at this point
Thanks for the help. I will try it out and see what I can come up with.
simacaj is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:29 PM.


Advertisement
Log in to turn off these ads.