HomePHP Page 6 - Clicking Through: A phpBanner Primer
Hooking Up - PHP
As your Web site gets more and more popular, you're going to need a capable banner management program to help you keep track of customers, banners and clicks. Take a look at phpBanner, which just might be what you're looking for!
Once all the clients and banners are set up, all that's left is to add the phpBanner hooks to your Web pages so that the banners start appearing. In order to better understand this, consider the following simple HTML page:
Now, let's suppose I want to add a banner to this page. I've got my phpBanner all set up with client information and a bunch of banners. The first step, then, is to include some required files at the top of my HTML (now PHP) page.
Note the use of the complete path to the phpBanner application.
Next, I need to use the phpBanner-supplied get_banner() function to actually display a banner. This function takes two arguments: the key that decides how a banner is to be selected from the pool of available options, and a value to be used when performing the selection.
The first argument to get_banner() can be any one of client (select banners by client ID), keyword (select banners by keyword) or size (select banners on the basis of their size). The first one is useful if you net a client who wants exclusive advertising on your site, the second one comes in handy when you're trying targeted advertising (you don't want to sell romance novels to a person browsing for technical books, do you?) and the third is useful if you have a page layout that can be destroyed by banners which do not conform to a pre-defined size.
The second parameter, obviously, is a value that must be combined with the chosen selection method in order to select a banner.
The return value of the function is an associative array containing the unique ID and the label text associated with the banner. You can use these two parameters to display the banner, as shown in the example below:
When this page is accessed through a Web browser, phpBanner will wake up, read the argument passed to get_banner() function -- the keyword client and client ID -- and display a banner corresponding to that client.
If you look at the source of this page in your browser, you'll see that the call to
<? $banner=get_banner("client","1"); ? >
returns an array that contains two parameters. The next line of code makes use of these two parameters to display the image and output the link associated with the banner.
Two important URLs to remember here: the one that returns the image associated with the banner, and the one that returns the URL associated with the banner Both these URLs require the banner ID as a GET parameter (as shown above).