GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   A simple PHP script for rotatin(random) banner with url (https://gfy.com/showthread.php?t=439177)

spamofon 03-02-2005 07:11 PM

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

Vell 03-02-2005 07:12 PM

phpadsnew - not 'simple' but the best there is

Yug 03-02-2005 07:14 PM

Quote:

Originally Posted by Vell
phpadsnew - not 'simple' but the best there is

:thumbsup

spamofon 03-02-2005 07:26 PM

Quote:

Originally Posted by Vell
phpadsnew - not 'simple' but the best there is


where can i get that?

spamofon 03-02-2005 08:13 PM

does that mean google it?

azguy 03-02-2005 09:37 PM

Just create an array with the links and their banner filename, shuffle it, and use the first item.

MrIzzz 03-02-2005 09:40 PM

i'm in the process of installing phpadsnew now and it fucking rocks. amazing features in there but it takes alot of tinkering

HowlingWulf 03-02-2005 10:10 PM

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];
?>

eadweb 03-02-2005 10:23 PM

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; } ?>

Lycanthrope 03-02-2005 10:26 PM

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

rickholio 03-02-2005 10:38 PM

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>";
?>

HTH. HAND. :thumbsup

Doc911 03-02-2005 10:49 PM

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