Banner Ads


Searching High and Low

After searching high and low for a useful "Rollover Banner Advert" PHP script on the internet, I came to the conclusion that most of what was out there was not very good. Typically, the scripts that I found would just display a single image (sometimes at "random") which was not really what I wanted it to do at all.


My Requirements

I wanted a script that would update the images every n seconds, that I could state when an image (ie. advert) should run for (ie. start and end date), how long the image should be displayed before "rolling over", and have a default advert in the case that there were no current adverts.


My Solution

My solution was to write the script myself using a combination of PHP and DHTML (ie. JavaScript). Now before you turn your nose up at the mention of JavaScript, be aware that a "Run Once" PHP script has certain limitations - chiefly that when it has finished generating the HTML, the script exits. This explains the many "Random" single image Banner Advert scripts out there.....

I found that the simplest solution was to parse through a configuration file (to determine which ads to run) and generate the HTML/ DHTML on that basis. The DHTML deals with the "Rollover" of the images, and updating of the Anchor (<A>) location (ie. When you click on the advert, it takes you where you want it to!).

Oh yeah, you can see it in effect at the top of this page! Not to mention on other sites.


I Want To Use It

If you like the script and decide to use it, please either:

OK, How Do I Use It?

If you already use PHP pages, the easiest way to use it to just "include" into your target PHP page
(e.g. <?PHP include "./Ads.php"; ?>).

If you use HTML pages (ie. no PHP features in the pages), you will need to either use the Ads.php file as a <FRAME> or <FRAME> setting src="./Ads.php".

Works With:

Note: your web server must support PHP to use this script!

  • Server
    • PHP 4.1
    • Apache (1.3.22) Web Server
    • Linux/ Windows NT
  • Client
    • Microsoft Internet Explorer 5, 5.5 and 6.0
    • Netscape/ Mozilla
    • Opera

Download

Download the BannerAds.zip file (sorry Linux/ Unix users: not got a tar/ gzip version of that file yet!), unzip the file to your required directory (which will probably be somewhere on an Apache Server.
The .zip file contains the following files:

BannerAds Version: 1.1
Files Needed for the Ad Banner code to work:
Ads.php			- The PHP script
AdTest.html		- A simple HTML page that uses the Ads.php script
AdTest.php		- A simple PHP page that uses the Ads.php script
Ads\ads.csv		- The advert configuration file
Ads\AllGigs.gif		- Sample image file
Ads\CCS.gif		- Sample image file
Ads\KleenMachine.gif	- Sample image file

The Configuration File

The configuration file (Ads/ads.csv) is comma-separated and looks as follows:

StartDate,DurationMonths,AdDurationSecs,PipeSeparatedImages,URL
04/01/2003,-1,15,AllGigs.gif,http://www.AllGigs.co.uk/
04/01/2003,-1,15,CCS.gif,http://www.ccssolutions.co.uk/
04/01/2003,-1,15,KleenMachine.gif,http://go.to/kleenmachine/

The first line contains the column headings and should not be touched. The other lines define images and URLs to use for the adverts. Here's what each column means:

StartDateDefines when the advert should come into usage.DD/MM/YYYY format date
DurationMonths The number of months the ad should run for.-1 = Always
 0 = Don't run
>0 = Number of months
AdDurationSecs The number of seconds the image should be displayed before rolling-over to the next ad> 0
PipeSeparatedImagesThe filenames of all images to use for this particular ad. If you wish to use more than one image, you can use the | character to delimit each file.Valid image filename(s)
URL The URL to visit if the advert is clicked upon.The full URL to link to (including http:// if it's a web page)

In our example file (above) we have three adverts. Each of them will always run, as the DurationMonths values are -1. Each advert will display for 15 seconds.

Try it!


Sites Using The Script


The Bad Guys

There are actually quite a few sites already using this script - but they won't get a mention as they have not added a link to AllGigs or have not left the AllGigs banner ad in place.
Did you miss that bit? Read about the one and only requirement for you to use this script: here


The Good Guys

www.HarmonyWeb.co.uk
reallfreestuff.com
www.pool-a-bet.co.uk

If you're a good guy, tell us that you are using the script and we'll add your site here!

Parting Comments

I hope you have found this useful. None of it is rocket science, and I hope that it is all self-explanatory. There is scope to modify the code (for randomness/ usage of a database - e.g. mySQL), but I have intentionally kept the whole thing simple (hopefully!)

Please feel free to pass your comments onto: enquiries@AllGigs.co.uk

Again, if you do decide to use the script: please see this note

Adverts - Advertise here

© 2001 - 2008 AllGigs Ltd. All Rights Reserved. Use of this site is subject to our Terms and Conditions.

Site Meter