Greenguy's Board


Go Back   Greenguy's Board > Programming & Scripting
Register FAQ Calendar Today's Posts

 
 
Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 2006-01-09, 04:45 PM   #2
Halfdeck
You can now put whatever you want in this space :)
 
Halfdeck's Avatar
 
Join Date: Oct 2004
Location: New Haven, CT
Posts: 985
Send a message via ICQ to Halfdeck
Top of the page (before any HTML):

PHP Code:
<?php

function random_link() {
   
$links = array("teen link" => "http://link1.com""mature babes" => "link2.com","horny sluts" => "link3.com");
   
shuffle($links); // randomize
   
list($linktext$url) = each($links); // pull the first link on the list
   
echo "<a href='$url'>$linktext</a>"// display it
}

?>
Then use <? random_link(); ?> in your HTML where ever you want the link displayed.

P.S. I'm not sure how random the shuffle() function is.

You can also create a random_link.php file, dump the code in there, then do an include where you want the link displayed:

<? include('path to file..../random_link.php'); ?>

Personally though, I would stick with JS, because with PHP you're adding a slight load on the server. Also, I'm sure you can use an external JS file and just call the function in your HTML. Only time I'd use PHP for something like this is if I was dealing with hundreds of links.
__________________
Success is going from failure to failure without a loss of enthusiasm.
Halfdeck is offline   Reply With Quote
 


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 -4. The time now is 06:05 AM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc