The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 19, 2019, 05:39:42 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Simple ad rotater  (Read 1886 times)
dink
Expert
****
Offline Offline

Posts: 349


View Profile
« on: May 01, 2007, 02:24:43 PM »

Here is a simple rotate script.

Code:
// rotate.php

<?php

$fcontents 
join (''file ('info.txt'));  // the text file can be any name you want
$s_con split("~",$fcontents);

$ad_no rand(0,(count($s_con)-1));
echo 
$s_con[$ad_no];

?>


The text file:
Code:

// info.txt
<a href="##"><img src="thong.jpg">Standard Thong</a><br />
~
<a href="##"><img src="p_thong.jpg">Pink Thong</a><br />
~
<a href="##"><img src="L_thong.jpg">Earl's Thong</a><br />
~
<a href="##"><img src="s_thong.jpg">Dink's Thong</a><br />


And finally, the useage:

Code:
//  pink_thongs.php

<html>
.
.
.
.
<p>
Before you leave, please see our most recent sales items.  Here is a preview of the exciting bargains available. 
<? include("rotate.php"); ?>
</p>
.
.
.
</html>

The rotate script will rotate anything that you have in the text file.  It is useful for inserting random strings in dynamic (db) description fields, in meta description fields, and the way I use it the most....different ppc ads on every page load.

You should note that you can have multiple rotates on each page.  ie, rotate.php, rotate1.php, etc.  As long as you have different text files to get your stuff from.  Additionally, you can name rotate.php anything you would like (as long as it doesn't match any other names in your system).  The rotate.php script above could have been named thongs.php and it would do the same thing.


Dink
Logged

[quote Nutballs]
the universe has a giant fist, and its got enough whoop ass for everyone.
[/quote]
NYDAz
Expert
****
Offline Offline

Posts: 212

The Night Stalker


View Profile
« Reply #1 on: March 31, 2009, 02:07:26 PM »

Since 2 years nobody said thank you for this little handy script ?  ROFLMAO

Let me be the first one ! Thanks  Applause  Vomit
Logged

what's up?
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!