Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 7 of 7

Thread: Ad rotating

  1. #1
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default Ad rotating

    K, ive got 4 pages.

    ads/ad1.html
    ads/ad2.html
    ads/ad3.html
    ads/ad4.html

    they all have a simple html code like <a href="url" target="_blank"><img src="url"></a>

    I want to use php include to include 1 of them randomly each time on my homepage. How would i do that?
    Lets set the stage on fire, and hollywood will be jealous.

  2. #2
    Join Date
    Nov 2006
    Location
    Cheshire.
    Posts
    730
    Tokens
    250

    Default

    PHP Code:
    <?php

       $rand 
    rand(14);
       if(
    $rand == 1)
       {

           include(
    "ads/ad1.html");

       }
       if(
    $rand == 2)
       {

           include(
    "ads/ad2.html");

       }
       if(
    $rand == 3)
       {

           include(
    "ads/ad3.html");

       }
       if(
    $rand == 4)
       {

           include(
    "ads/ad4.html");

       }

    ?>
    Hope it helps.

  3. #3
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default

    Thanks Frog!

    +Rep
    Lets set the stage on fire, and hollywood will be jealous.

  4. #4
    Join Date
    Sep 2007
    Location
    USA
    Posts
    474
    Tokens
    0

    Default

    One Second Here Finding it

    This is a code invent posted on clubhabbo its a random link generator
    there should be a code simliar or this code could be edited to show the pages instead

    <?php

    // stuff to poke
    $stuff[ 0 ] = '<a href="http://www.habbo.co.uk/home/NAME">NAME </a>';
    $stuff[ 1 ] = '<a href="http://www.habbo.co.uk/home/NAME">NAME 1</a>';
    $stuff[ 2 ] = '<a href="http://www.habbo.co.uk/home/NAME">NAME 2</a>';
    $stuff[ 3 ] = '<a href="http://www.habbo.co.uk/home/NAME">NAME 3</a>';
    $stuff[ 4 ] = '<a href="http://www.habbo.co.uk/home/NAME">NAME 4</a>';
    $stuff[ 5 ] = '<a href="http://www.habbo.co.uk/home/NAME">NAME 5</a>';
    $stuff[ 6 ] = '<a href="http://www.habbo.co.uk/home/NAME">NAME 6</a>';
    $stuff[ 7 ] = '<img src="http://www.habbo.co.uk/habbo-imaging/avatarimage?user=NAME&action=wve&frame=3&direction =4&head_direction=4&gesture=sml&img_format=gif">' ;
    $stuff[ 8 ] = '<img src="http://www.habbo.co.uk/habbo-imaging/avatarimage?user=NAME&action=wve&frame=3&direction =4&head_direction=4&gesture=sml&img_format=gif"> 2';

    //Dont poke this, it'll work, just change values above and add/remove from em
    $display=rand(0, sizeof($stuff)-1);
    echo $stuff[$display];
    ?>
    ?>
    Oringinal Plot of Reason for Invent's Code:
    <?php
    //SET BANNER URLS.
    $banner1 = "banner1_url_here.gif";
    $banner2 = "banner2_url_here.gif";
    $banner3 = "banner3_url_here.gif";
    $banner4 = "banner4_url_here.gif";
    //FINISH SETTING BANNER URLS.

    $rand_func = rand(1,4); //This code will make the random banner easier.

    if($rand_func == '1') {
    echo("<img src=\"$banner1\">"); //Prints the banner image to the page if the banner number to show is 1.
    }

    if($rand_func == '2') {
    echo("<img src=\"$banner2\">"); //Prints the banner image to the page if the banner number to show is 2.
    }

    if($rand_func == '3') {
    echo("<img src=\"$banner3\">"); //Prints the banner image to the page if the banner number to show is 3.
    }

    if($rand_func == '4') {
    echo("<img src=\"$banner4\">"); //Prints the banner image to the page if the banner number to show is 4.
    }
    ?>
    so actually if its ad banners it will be quite easier as a image
    Post Meter
    ______________________________________________
    400 450 500 550 600 650 700 750 800 850 900-1k
    Green=Done | Orange=Almost | Red=Not Done
    ______________________________________________
    Habbo fury Coming Soon!
    My Img tag has ran away

  5. #5
    Join Date
    Sep 2006
    Location
    Hobart, Australia
    Posts
    593
    Tokens
    0

    Default

    Quote Originally Posted by LegendOfNoob View Post
    One Second Here Finding it

    This is a code invent posted on clubhabbo its a random link generator
    there should be a code simliar or this code could be edited to show the pages instead



    Oringinal Plot of Reason for Invent's Code:


    so actually if its ad banners it will be quite easier as a image
    I'd go for a solution like this rather than the technique you are using above, as it's all in the one file, rather than having a file for each ad

  6. #6
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    529
    Tokens
    0

    Default

    Or to shorten the other guys code:

    PHP Code:
    <?php

       $rand 
    rand(14);
       include(
    "ads/ad".$rand."");

    ?>

  7. #7
    Join Date
    Aug 2006
    Location
    Manchester, UK
    Posts
    2,016
    Tokens
    141
    Habbo
    florx

    Latest Awards:

    Default

    Or use javascript. (nicked from clubhabbo)

    HTML Code:
    <script type="text/javascript">
    
            var preloaded = new Array();
            function preloadImages() {
                    for (var i = 0; i < arguments.length; i++){
                            preloaded[i] = document.createElement('img');
                            preloaded[i].setAttribute('src',arguments[i]);
                    };
            };
    preloadImages(
    '/images/sitebanners/council.gif',
    '/images/sitebanners/voteofficial.gif'
    
    );
    
    var links = new Array(
    '/news/show_news.php?subaction=showfull&id=1196059919&archive=&start_from=&ucat=25&',
    '/news/show_news.php?subaction=showfull&id=1195081110&archive=&start_from=&ucat=25&'
    
    );
    
    var text = new Array(
    '<b>The ClubHabbo Council</b> has returned, and we are hiring new Council Members!',
    'Official UK Fansite voting is open, and ClubHabbo needs <b>YOUR</b> vote!'
    
            );
    
            var curOffset = 1;
    
            window.onload=function() {
                    document.getElementById('randLink').href = links[0];
                    document.getElementById('randImage').src = preloaded[0].src;
                    document.getElementById('randText').innerHTML = text[0];
                    setInterval(
                    function() {
                            document.getElementById('randLink').href = links[curOffset];
                            document.getElementById('randImage').src = preloaded[curOffset].src;
                            document.getElementById('randText').innerHTML = text[curOffset];
                            curOffset = (curOffset >= preloaded.length-1) ? 0 : curOffset + 1;
                    }, 10000);
            };
    </script>
    In the head tag.

    In the body tag:

    HTML Code:
    <a id="randLink" href="#"><img src="" border="0" id="randImage"></a></div>
    <div id="randText">
    </div>

Posting Permissions

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