+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 10 of 15

Thread: [TUTORIAL] Rotative Banners in PHP

  1. #1
    x10 Elder DarkDragonLord is an unknown quantity at this point DarkDragonLord's Avatar
    Join Date
    Mar 2007
    Location
    Brazil
    Posts
    782

    [TUTORIAL] Rotative Banners in PHP

    Greetings everyone :D

    Well, here its a fully commented PHP Script that allows you to create a rotative banner and yet, set up the href/link to the website.

    I did not made it but i did translated all comments since were in PORTUGUESE.

    PHP Code:

    <?php
    $banners 
    = array('http://ddl.exofire.net/images/banner2.gif','http://ddl.exofire.net/images/468x80_banner.gif');

    /* here is where is created the variable array type where you will be inserting the name of the images. FULL URL, */

    $totalbanners count($banners);

    /* Here we use the count instruction to check the number of images inside the variable $banners */

    $totalbanners--;

    /* here we make a recount of the total number returned by the count, because an array starts with index 0 */

    $randombanners rand(0,$totalbanners);

    /* the rand instruction ramdomly picks one image number generated by the count */

    $link = array('www.google.com.br','ddl.exofire.net');

    /* variable array type, that we define what is the URL of the HREF in the images. you must put in same order of the images.. NO NEED the http:/ because in the echo, we already add it. */

    $alts = array('its google lol','my website');


    echo 
    "<a href=\"http://$link[$randombanners]\">
    <img border=\"0\" width=\"yy\" height=\"xx\" src=\"
    $banners[$randombanners]\" alt=\"$alts[$randombanners]\">
    </a>"
    ;

    // ok, here we show the image ;P try it pressing F5 in your webpage ^^

    ?>
    Remember to set the width and height, this way, if you just want 468x80 banners, if any "smart" one changes it banner to a 1024x768 to **** your webpage, it will not show full size, just the size you setup'ed


    And i added the alt array just now so, i think will work perfectly, if not, let me know.
    Credits:
    http://www.baboo.com.br/absolutenm/t...eid=24&resumo=
    Last edited by DarkDragonLord; 10-26-2007 at 03:54 PM.
    Regards,
    Raphael DDL

    Designing Solutions for You
    *Web Design;
    *Coding;
    Free Downloads;
    and all related Stuff
    .


    My Tutorials:
    | Multi-Language Websites | Rotative Banners |
    | Bookmark Script for All Browsers
    |
    |
    PHP Switching/Including Content|
    |


  2. #2
    x10Hosting Member engel is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    54

    Re: [TUTORIAL] Rotative Banners in PHP

    I have an alternative method to doing this:
    (Before running the script, insert a banner code, one per line, into a file called banners.txt.
    PHP Code:
    <?php

    function display_banners() {
        
    $banners file("banners.txt");
        
    shuffle($banners);
        echo 
    $banners[0];
    }

    ?>
    Then just call display_banners(); wherever you want to display it.

  3. #3
    x10 Lieutenant Thewinator is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    [NL]
    Posts
    256

    Re: [TUTORIAL] Rotative Banners in PHP

    I have to say that DDL's one could use a function as well to easily place it where you want it to.
    But engels solution to put it in a txt file isn't the way to go.
    If anyone knows the url of the txt file they could access it and that looks bad.
    Also the method DDL used is 'Fool-proof' so to speak.
    While engels could for instance be riged with:
    <meta http-equiv="refresh" content="0;URL=google.com" />

  4. #4
    Where's North from here? vigge_sWe is an unknown quantity at this point vigge_sWe's Avatar
    Join Date
    Oct 2007
    Location
    Göteborg, Sweden
    Posts
    4,799

    Re: [TUTORIAL] Rotative Banners in PHP

    Hi! I have the Ad management mod on my phpBB 3 and I want to add rotative banners in it. Apparently, I know putting php in an html document never works so how should I do it?







  5. #5
    x10 Lieutenant Thewinator is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    [NL]
    Posts
    256

    Re: [TUTORIAL] Rotative Banners in PHP

    I would mod the mod to alow php files anyway

  6. #6
    Where's North from here? vigge_sWe is an unknown quantity at this point vigge_sWe's Avatar
    Join Date
    Oct 2007
    Location
    Göteborg, Sweden
    Posts
    4,799

    Re: [TUTORIAL] Rotative Banners in PHP

    But how should I do???







  7. #7
    x10 Lieutenant Thewinator is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    [NL]
    Posts
    256

    Re: [TUTORIAL] Rotative Banners in PHP

    Well that depends on how your mod works, try reading through its php files and look for the method that places the images, then just replace it with a div and an include within that div
    Last edited by Thewinator; 10-27-2007 at 01:28 PM.

  8. #8
    x10 Elder QuwenQ is an unknown quantity at this point QuwenQ's Avatar
    Join Date
    Sep 2007
    Location
    Alamosa, CO
    Posts
    977

    Re: [TUTORIAL] Rotative Banners in PHP

    Quote Originally Posted by vigge_sWe View Post
    But how should I do???
    Get SMF.
    Simple as that.
    A million and one more mods.

  9. #9
    Where's North from here? vigge_sWe is an unknown quantity at this point vigge_sWe's Avatar
    Join Date
    Oct 2007
    Location
    Göteborg, Sweden
    Posts
    4,799

    Re: [TUTORIAL] Rotative Banners in PHP

    Quote Originally Posted by Thewinator View Post
    Well that depends on how your mod works, try reading through its php files and look for the method that places the images, then just replace it with a div and an include within that div
    The mod hasn't any php... Only html...







  10. #10
    x10 Lieutenant Thewinator is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    [NL]
    Posts
    256

    Re: [TUTORIAL] Rotative Banners in PHP

    Quote Originally Posted by vigge_sWe View Post
    The mod hasn't any php... Only html...
    Are you sure its not the templates your looking at?
    Either way you could place an iframe and use DDL's script.



+ Reply to Thread
Page 1 of 2
1 2 LastLast

Similar Threads

  1. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  2. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  3. Sigo con problemas con phpbb2
    By reciecho in forum Soporte
    Replies: 7
    Last Post: 10-20-2007, 06:28 PM
  4. "PHP Startup: Invalid Library" - Interesting error
    By javaguy78 in forum Free Hosting
    Replies: 5
    Last Post: 03-27-2007, 02:33 PM

Posting Permissions

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