Home
Developer Blog
Ajax effects
CSS examples
Freelance jobs
Hot IT Jobs
Hot scripts
Code samples
Web hosting directory
Lotus Notes FAQ
See the new scripts recently added to Dynamic Drive.
Click here
.
Original, practical
CSS codes and examples
such as CSS menus for your site.
-->
Search code samples
Keyword
All Categories
ASP
CSS
Dhtml
Html
Javascript
PHP
Code Samples
ASP
CSS
Dhtml
Html
Javascript
PHP
LOGIN HERE
Username
Password
Signup Now
Forgot Password
Verify Signup
PHP >> General
how to display Random Links (Text or Image) using php?
Visitor Ratings (2) :
Description
Code
Select All
<? //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>"; } ?>
Rate this Resource
0
1
2
3
4
5
6
7
8
9
10
Related Links:
Earn revenue from
your website's traffic.
High quality Website Templates
Shopping cart store builder
Best hosting plans
Reliable hosting for $6.95!
FreeLance Jobs from ODesk!
Reliable Unlimited domain hosting for $4.95!
Premium Templates
Home
Blog
Ajax
CSS
Hot scripts
Tips & Tricks
Webmaster Resources
Freelance jobs
Articles
Sitemap
Website builder and Cheap domain names
Lotus Notes FAQ
Our partners