Creating Websites That Work! Call Toll Free at 1-877-530-7993 For Assistance With Your Web Needs.
Design Solutions
E-commerce
Hosting Plans
Other Services
PHP - Random Links

1.) Call this script using SSI or use it directly in your php pages.

<?

//Do you want to use text or an image for the link;
//enter either text or image

$showme= 'text';

//You're text file should be in the following format each set on it's own line:
//For text links
//     Location to go to|What you'd like the link to say
//     Location to go to2|What you'd like the link to say2
//For image links
//     Location to go to|Location of the corresponding image
//     Location to go to2|Location of the corresponding image2

//Either put the text file db in the same folder as this script or use the actual path.
//For example /u/web/your_id/files/db.txt

define("myDataFile", "db.txt"); //If in the same folder otherwise use actual path
$content = file(myDataFile);
srand((double)microtime()*1000000);
$randline = rand(0,count($content)-1);
$link = explode("|",$content[$randline]);
if ($showme == 'text'){
echo "<a href=\"$link[0]\">$link[1]</A>";
}
else{
echo "<a href=\"$link[0]\"><img src=\"$link[1]\"></A>";
}

?>

 

 

Learning Center
About Us
Create-A-Website provides you with professional custom web solutions at affordable prices!