• Archives

  • Displaying random advertisement through php

    By admin | January 1, 2008

     

    Sometimes you want to display something randomlythis tutorial is going to teach how to display two company advertisement on the same page like google and bidvertiser.

    Syntax:

    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
    <html xmlns=”http://www.w3.org/1999/xhtml”>
    <head>
    <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
    <title>Untitled Document</title>
    </head>
    <body>
    <?php
    $a = rand (1,2);
    if ($a == “1″) {
    ?>
    <script type=”text/javascript”>
    <!–
    google_ad_client = “”;
    //728×90, created 12/31/07
    google_ad_slot = “1167745697″;
    google_ad_width = 728;
    google_ad_height = 90;
    //–>
    </script>
    <script type=”text/javascript”
    src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”>
    </script>
    <?php
    }
    if ($a == “2″) {
    ?>
    <!– Begin BidVertiser code –>
    <SCRIPT LANGUAGE=”JavaScript1.1″ src=”http://bdv.bidvertiser.com/BidVertiser.dbm?pid=&bid=” type=”text/javascript”></SCRIPT>
    <noscript><a href=”http://www.bidvertiser.com/bdv/BidVertiser/bdv_advertiser.dbm”>pay per click</a></noscript>
    <!– End BidVertiser code –>
    <?php

    }

    ?>
    </body>
    </html>

    You must have understand now that we assign a randomly between 1 and 2 and then check if a = 1 then display google advertisement and if a = 2 then display bidvertiser advertisement.

    Thanks

    krates

    Topics: PHP | Comments Off on Displaying random advertisement through php

    Related Links: