PHP
  Home arrow PHP arrow Page 6 - Clicking Through: A phpBanner Primer
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Clicking Through: A phpBanner Primer
By: Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 16
    2004-04-21

    Table of Contents:
  • Clicking Through: A phpBanner Primer
  • Start Me Up
  • Client Server
  • Of Pictures and Words
  • Hits And Misses
  • Hooking Up
  • Different Strokes
  • Clicking Through

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Clicking Through: A phpBanner Primer - Hooking Up


    (Page 6 of 8 )

    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:


    <html>
    <head>
    <basefont face="Arial">
    </head>
     
    <
    body>
     
    <
    table height="100%" width="100%" border="0" cellspacing="5"
    cellpadding
    ="5"> <tr>
     
    <td align="center">Ad goes here</td>
    </tr>
    <tr>
     
    <td height="100%" width="100%" valign="top" bgcolor="silver"
    align
    ="left">
     
    <h2>Sample page</h2>
     
    <center>
     Content here
     
    <p>
     Content here
     
    <p>
     Content here
     
    <p>
     
    </center>
     
    </td>
    </tr>
    </table>
     
    </
    body>
    </html>

    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.


    <?
    require
    ("/www/htdocs/phpbanner/require/config.php");
    require
    ("/www/htdocs/phpbanner/require/banner.php");
    ? >

    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:


    <?
    require
    ("/www/htdocs/phpbanner/require/config.php");
    require
    ("/www/htdocs/phpbanner/require/banner.php");
    ? >
    <html>
    <head>
    <basefont face="Arial">
    </head>
     
    <
    body>
     
    <
    table height="100%" width="100%" border="0" cellspacing="5"
    cellpadding
    ="5"> <tr>
     
    <td align="center">
    <? 
    $banner
    =get_banner("client","1");
    ? >
     
    <a href="http://www.mysite.com/phpbanner/link.php?banner_id=<?echo
    $banner[id];? >"
    >
    <img border=0
    src
    ="http://www.mysite.com/phpbanner/view.php?banner_id=<?echo
    $banner[id];? >" 
    alt="<?echo $banner[alt];? >">
    </a></td>
    </tr>
    <tr>
     
    <td height="100%" width="100%" valign="top" bgcolor="silver"
    align
    ="left">
     
    <h2>Sample page</h2>
     
    <center>
     Content here
     
    <p>
     Content here
     
    <p>
     Content here
     
    <p>
     
    </center>
     
    </td>
    </tr>
    </table>
     
    </
    body>
    </html>

    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.


    <?
     
    <
    a href="http://www.mysite.com/phpbanner/link.php?banner_id=<?echo
    $banner[id];? >"
    >
    <img border=0
    src
    ="http://www.mysite.com/phpbanner/view.php?banner_id=<?echo
    $banner[id];? >" 
    alt="<?echo $banner[alt];? >">
    </a>
     
    ? >


    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).

    More PHP Articles
    More By Harish Kamath, (c) Melonfire


     

       

    PHP ARTICLES

    - Using Aliases and the Autoload Function with...
    - Authentication Scripts for a User Management...
    - Utilizing the Use Keyword for Namespaces in ...
    - Building a User Management Application
    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Sub Classing Exceptions in PHP 5
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT