![]() |
A simple PHP script for rotatin(random) banner with url
anyone has anything like that
just want to rotate different banners on page, anyone have any simple php script to do that? thanks |
phpadsnew - not 'simple' but the best there is
|
Quote:
|
Quote:
where can i get that? |
does that mean google it?
|
Just create an array with the links and their banner filename, shuffle it, and use the first item.
|
i'm in the process of installing phpadsnew now and it fucking rocks. amazing features in there but it takes alot of tinkering
|
Your subject says random, which is easier than incremental rotate, so here you go.
<?php $ban = array(); array_push($ban,"HTML CODE1"); array_push($ban,"HTML CODE2"); array_push($ban,"HTML CODE3"); srand ((double)microtime()*1000000); $randomnum = rand(0, count($ban)-1); echo $ban[$randomnum]; ?> |
I create a files called banner1.php, banner2.php... etc. 1 for each banner spot and then call them with a php include statment.
<?php srand((double)microtime()*1000000); switch (rand (1,5)) { case 1: ?> <a href=http://www.YourSponsor.com/ target=_blank> <img src=/banners/YourBanner.gif width=468 height=80 border=0 alt="Click Here!"></a> <? break; case 2: ?> <a href="http://www.YourSponsor.com/" target="_blank"> <img src="/banners/YourBanner.gif" width=468 height=60 border=0 alt="Click Here!"><br> <font face="Arial,Helvetica" size="3">Visit The Webs Largest Sex Personals Site... Join For Free!</font></a> <? break; case 3: ?> <a href=http://www.YourSponsor.com/ target=_blank> <img src=/banners/YourBanner.gif width=468 height=80 border=0 alt="Click Here!"></a> <? break; case 4: ?> <a href="http://www.YourSponsor.com/" target="_blank"> <img src="/banners/YourBanner.gif" width=468 height=60 border=0 alt="Click Here!"><br> <font face="Arial,Helvetica" size="3">Visit The Webs Largest Sex Personals Site... Join For Free!</font></a> <? break; case 5: ?> <a href="http://www.YourSponsor.com/" target="_blank"> <img src="/banners/YourBanner.gif" width=468 height=60 border=0 alt="Click Here!"><br> <font face="Arial,Helvetica" size="3">Visit The Webs Largest Sex Personals Site... Join For Free!</font></a> <? break; } ?> |
banners.php (include this)
<? $delim = "\n"; $cryfile = "banners.txt"; $fp = fopen($cryfile, "r"); $contents = fread($fp, filesize($cryfile)); $cry_arr = explode($delim,$contents); fclose($fp); srand((double)microtime()*1000000); $cry_index = (rand(1, sizeof($cry_arr)) - 1); $herecry = $cry_arr[$cry_index]; echo $herecry; ?> banners.txt <a href="url1.com"><img border="0" src="image1.gif"></a> <a href="url2.com"><img border="0" src="image2.gif"></a> <a href="url3.com"><img border="0" src="image3.gif"></a> more here 1 per line |
Yikes... there's some helluva inefficient ways being proferred here. Just goes to show that there's 100 ways to do something on a computer I suppose.
Here's an alternative that allows you to attach a separate banner with a URL, simple maintenance by adjusting array elements. Easily adapted to keeping image/URL pairs in a database. Code:
<? |
I can write that script with a simple admin panel to add or remove the banners for 20 bucks icq me at 161480555
|
All times are GMT -7. The time now is 11:09 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123