Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2006
    Posts
    1,463
    Tokens
    0

    Latest Awards:

    Lightbulb Create a random banner advertisement rotator

    PHP Code:
    <?php // Start PHP so the server knows to parse anything below this as PHP
    $ads = array(); // Start an array
     
    $ads[] = '<a href="http://www.domain.com"><img src="/banners/ad1.gif" alt="domain's banner" /></a>';
    // We have created our first ad. We simple just put the format of the ad within an 
    $ads[] variable. We can add as many ad's as we want as it is an array and won't overwrite the variable.
     
    $ads[] = '<a href="http://www.domain2.com"><img src="/banners/ad2.gif" alt="domain2's banner" /></a>';
    //We have no added another. Now we will display the ad's.
     
    shuffle($ads); 
    // We will use the PHP function shuffle to randomise our advertisements. 
     
    echo $ads[0];
    // We echo the first ad in the array. The array has been shuffled so the first ad will change.
     
    ?> //Stop parsing as PHP
    Im newb to PHP so yeh
    you have now created your ad's
    Last edited by Rockstar; 07-11-2007 at 04:42 PM.

  2. #2
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    Cool tut =]

    Maybe use the
    PHP Code:
    PHP 
    tags though while posting?
    Coming and going...
    Highers are getting the better of me

  3. #3
    Join Date
    Apr 2006
    Posts
    1,463
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Cj555 View Post
    Cool tut =]

    Maybe use the
    PHP Code:
    PHP 
    tags though while posting?
    I didnt know how to I tryed
    But didnt work

  4. #4
    Join Date
    Dec 2006
    Location
    Swindon
    Posts
    3,299
    Tokens
    215
    Habbo
    dunko

    Latest Awards:

    Default

    Sorry, I just had to edit it.

    PHP Code:
    <?php // Start PHP so the server knows to parse anything below this as PHP
    $ads = array(
    '<a href="http://www.domain.com"><img src="/banners/ad1.gif" alt="domain\'s banner" /></a>''<a href="http://www.domain2.com"><img src="/banners/ad2.gif" alt="domain2\'s banner" /></a>'
    );
    //We have no added another. Now we will display the ad's.

    $rand rand(0count($ads);
    // We will use the PHP function shuffle to randomise our advertisements. 
     
    echo $ads[$rand];
    // We echo the first ad in the array. The array has been shuffled so the first ad will change.
     
    ?> //Stop parsing as PHP
    Should work

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •