Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

August 19, 2022, 08:39:26 PM

Login with username, password and session length
Members
  • Total Members: 3843
  • Latest: Tricky
Stats
  • Total Posts: 193479
  • Total Topics: 21088
  • Online today: 60
  • Online ever: 1035
  • (November 26, 2020, 04:45:12 AM)
Users Online
Users: 0
Guests: 45
Total: 45

Author Topic: Multiple banner ad rotator?  (Read 21238 times)

0 Members and 1 Guest are viewing this topic.

Adamzon

  • Guest
Multiple banner ad rotator?
« on: January 22, 2007, 05:44:34 AM »
Hi!
Im need a script to rotate up to 10 lines/banners on my site www.glidarhoj.se
I have tried some diffrent scripts with include but i cant get it to work  :idiot2:

Do u have any idea?
www.glidarhoj.se



Offline Ianedres

  • Friends
  • *
  • Posts: 685
  • $foo['ianedres'] < $foo['ichbin']
    • Clickity click dot dot dot com thingy
Re: Multiple banner ad rotator?
« Reply #1 on: January 22, 2007, 06:07:58 AM »
Something I've used before...

Code: [Select]
<?php
$filename 
"path_to\oneliners.txt";
$handle fopen($filename"rb");
$contents fread($handlefilesize($filename));
fclose($handle);

$ads explode("\n"$contents);
$totalads count($ads)-1;
$i rand(0$totalads);

echo 
$ads[$i];
?>

In the filename 'oneliners.txt', just make sure you point the script to the proper path for it. Each line is read by the script on a random basis. You can even include valid HTML code within each line.

JPDeni

  • Guest
Re: Multiple banner ad rotator?
« Reply #2 on: January 22, 2007, 08:21:58 AM »
Create a php block.

Put the following code in it, filling in the urls to your banners and links as needed, one per line:

Code: [Select]
$banners = array (
'<a href="http://link/to/site" target="_blank"><img src="http://url/to/img"></a>',
'<a href="http://link/to/site" target="_blank"><img src="http://url/to/img"></a>',
'<a href="http://link/to/site" target="_blank"><img src="http://url/to/img"></a>',
'<a href="http://link/to/site" target="_blank"><img src="http://url/to/img"></a>',
'<a href="http://link/to/site" target="_blank"><img src="http://url/to/img"></a>',
'<a href="http://link/to/site" target="_blank"><img src="http://url/to/img"></a>',
'<a href="http://link/to/site" target="_blank"><img src="http://url/to/img"></a>',
'<a href="http://link/to/site" target="_blank"><img src="http://url/to/img"></a>',
'<a href="http://link/to/site" target="_blank"><img src="http://url/to/img"></a>',
'<a href="http://link/to/site" target="_blank"><img src="http://url/to/img"></a>',
'<a href="http://link/to/site" target="_blank"><img src="http://url/to/img"></a>'
);

shuffle($banners);

echo $banners[0];

It's easy to edit, you don't have to have any external files, and you can have as many or as few banners as you want.

Adamzon

  • Guest
Re: Multiple banner ad rotator?
« Reply #3 on: January 22, 2007, 10:19:06 AM »
Great! But i need a multiple-line.

10 banners would be great

/Adam

JPDeni

  • Guest
Re: Multiple banner ad rotator?
« Reply #4 on: January 22, 2007, 10:43:39 AM »
Quote
But i need a multiple-line

Can you give me an example of what you need?

TolerancE

  • Guest
Re: Multiple banner ad rotator?
« Reply #5 on: January 22, 2007, 10:48:00 AM »
FINALLY! I've been looking for this for what seems like forever.

Adamzon

  • Guest
Re: Multiple banner ad rotator?
« Reply #6 on: January 22, 2007, 10:51:10 AM »
Look @ www.lidkopingsnytt.nu
in the right column (ads)
He has many diffrent ads, and they change places with every page open.

I have tried to inlude som diffrent php random banner generators but i cant get it to work :(
(in the big, all scripts that www.hotscripts.com has to offer in the randomize banner scripts)


/adam

JPDeni

  • Guest
Re: Multiple banner ad rotator?
« Reply #7 on: January 22, 2007, 10:59:51 AM »
Oh. You want multiple banners. Well that's easy enough.

Keep the same code as I gave you above. Instead of

Code: [Select]
echo $banners[0];

use

Code: [Select]
$number_of_banners = 4; // put the number of banners you want to display here;

for ($i = 0; $i < $number_of_banners; ++$i)
  echo $banners[$i] , '<br />';

Adamzon

  • Guest
Re: Multiple banner ad rotator?
« Reply #8 on: January 22, 2007, 11:13:00 AM »
OMG! U are wonderful!!! THANX!!

Is there anyway to specifie the width of the banners?

/Adam

JPDeni

  • Guest
Re: Multiple banner ad rotator?
« Reply #9 on: January 22, 2007, 11:14:44 AM »
Just put the height and width in the img tags like you would put it in any other html img tags. There's nothing magical about them. :)

You're welcome. ;D