![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Join Date: Jun 2003
Location: Toronto
Posts: 2,999
|
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 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
So Fucking Banned
Join Date: Sep 2003
Posts: 170
|
phpadsnew - not 'simple' but the best there is
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 | |
Confirmed User
Join Date: Dec 2002
Location: Brisbane, Australia
Posts: 218
|
Quote:
![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 | |
Confirmed User
Join Date: Jun 2003
Location: Toronto
Posts: 2,999
|
Quote:
where can i get that? |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Join Date: Jun 2003
Location: Toronto
Posts: 2,999
|
does that mean google it?
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Join Date: Nov 2004
Location: Scottsdale, AZ
Posts: 5,167
|
Just create an array with the links and their banner filename, shuffle it, and use the first item.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
If u touch it, I will cum
Join Date: Sep 2003
Location: long island
Posts: 22,923
|
i'm in the process of installing phpadsnew now and it fucking rocks. amazing features in there but it takes alot of tinkering
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Join Date: Nov 2001
Posts: 1,662
|
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]; ?> |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
Confirmed User
Join Date: Aug 2002
Location: Canada
Posts: 196
|
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; } ?>
__________________
I don't need no stinking sig. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 |
Confirmed User
Industry Role:
Join Date: Jan 2004
Location: Wisconsin
Posts: 4,517
|
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 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 |
Confirmed User
Industry Role:
Join Date: Jan 2004
Location: Nor'easterland
Posts: 1,914
|
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:
<? // Change the banner/URL mappings as you so desire. $b = array( 'banner1.jpg' => 'http://target.url1', 'banner2.jpg' => 'http://target.url2', 'banner3.jpg' => 'http://target.url3' ); // If you'd rather use mysql: // $q = mysql_query("select img, url from whatever_table order by rand() limit 1"); // $r = mysql_fetch_assoc($q); // $img = $r[img]; $url = $r[url]; $img = array_rand($b); // The easy way to pull a random element from an array ;) $url = $b[$img]; print "<A HREF='$url'><IMG SRC='$img' BORDER=0></A>"; ?> ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 |
Confirmed User
Join Date: Feb 2004
Location: If i was up your ass you'd know
Posts: 3,695
|
I can write that script with a simple admin panel to add or remove the banners for 20 bucks icq me at 161480555
|
![]() |
![]() ![]() ![]() ![]() ![]() |