Random Ads


First of all, create a file call random.php
PHP Code
  1. <?php
  2.  
  3. // load the file that contain the ads
  4. $adfile = "ads.txt";
  5. $ads = array();
  6.  
  7. // one line per ad
  8. $fh = fopen($adfile, "r");
  9. while(!feof($fh)) {
  10.  
  11. $line = fgets($fh, 10240);
  12. $line = trim($line);
  13. if($line != "") {
  14. $ads[] = $line;
  15. }
  16. }
  17.  
  18. // randomly pick an ad
  19. $num = count($ads);
  20. $idx = rand(0, $num-1);
  21.  
  22. echo $ads[$idx];
  23. ?>

everything is explained line per line
then create a txt file and call it ads.txt
PHP Code
  1. <a href="https://www." target="_blank"><img src="https://" width="468" height="60" border="0"></a>
  2. <a href="https://www.">some ad</a>
  3. <a href="https://www.">some more ad</a>

you can modify this as you want, i hope you just have a little knowledge of HTML...
then insert the following code in your page to display it
PHP Code
  1. <iframe marginwidth="0" marginheight="0" width="468" height="60" scrolling="no" frameborder=0 src="randomad.php">
  2. </iframe>

you can also modify this as you want...
for other features dont border to pm me ^^
gbt91's Avatar
Author:
Views:
2,773
Rating:
Posted on Wednesday 16th May 2007 at 04:12 PM
DanielXP
DanielXP's Avatar
Updated.
Posted on Wednesday 16th May 2007 at 12:04 PM
gbt91
gbt91's Avatar
oops...
since i took it from my page i forgot to take it off...
Posted on Tuesday 15th May 2007 at 08:11 PM
DanielXP
DanielXP's Avatar
What the JS function 'color_selected' for?