 | PHP Tutorials :: Random Images Tutorial |  |
11-13-2004, 09:01 AM
|
Warn webgear · View webgear's Warnings
· #1 | | Registered PLUS
webgear is
Offline:
Style: Posts: 25 WO Dollars: $32.00 Country: | PHP Tutorials :: Random Images Tutorial Step 1.
First Make these files:
- random.txt
- random.php
Now open your random.txt and do the following to display your pictures:
<img src="image1.gif">
<img src="image2.gif">
etc...
If you want to add a link to your images (e.g. Banner Advertising) , just do the following
<a href="linkhere.php"><img src="image.gif" border="0"></a>
<a href="linkhere2.php"><img src="image2.gif" border="0"></a>
ect...
Step 2.
Now open your random.php and add the code below to it:
<?php
$random = "random.txt";
$fp = file($random);
srand((double)microtime()*1000000);
$rl = $fp[array_rand($fp)];
echo $rl;
?>
Step 3.
Now copy the code below and add it to any page you desire to display your random images. Remember this will only work if the page its on has a .php extension.
<?php include("random.php"); ?>
And There You Go! Have Fun! | |
| |
11-22-2004, 01:50 AM
|
Warn Steve · View Steve's Warnings
· #4 | | WMT Addict PLUS
Steve is
Offline:
WMT Contributor Style: Posts: 911 WO Dollars: $90.00 Country: | Hmm. Nice and simple, the way I like it.  | |
| | | Thread Tools | Search 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 HTML code is Off | | | |