Ad Rotate Help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Ad Rotate Help

    Hi, how can make this script allow me to use php include so i can randomize my ads.

    When use php include i get an error.

    PHP Code:
    <?php
    $quot_arr 
    = array(
    '<a href="http://example.com">Example</a>',);
    '<a href="http://example.com">Example</a>',);
    '<a href="http://example.com">Example</a>',);
    '<a href="http://example.com">Example</a>',);
    '<a href="http://example.com">Example</a>',);
    '<a href="http://example.com">Example</a>',);
    '<a href="http://example.com">Example</a>',);
    '<a href="http://example.com">Example</a>',);
    $quot_rand array_rand($quot_arr);
    echo 
    '<center><b>AD:  </b>';
    echo 
    ' '.$quot_arr[$quot_rand].'</left>';
    ?>
    or if there is a better ad rotate script without sql so that i can use with buzzcity,adiquity,reporo etc etc

    Thanks

    #2
    Originally posted by brentg View Post
    Hi, how can make this script allow me to use php include so i can randomize my ads.
    When use php include i get an error.
    PHP Code:
    <?php
    $quot_arr 
    = array(
    '<a href="http://example.com">Example</a>',);
    '<a href="http://example.com">Example</a>',);
    '<a href="http://example.com">Example</a>',);
    '<a href="http://example.com">Example</a>',);
    '<a href="http://example.com">Example</a>',);
    '<a href="http://example.com">Example</a>',);
    '<a href="http://example.com">Example</a>',);
    '<a href="http://example.com">Example</a>',);
    $quot_rand array_rand($quot_arr);
    echo 
    '<center><b>AD:  </b>';
    echo 
    ' '.$quot_arr[$quot_rand].'</left>';
    ?>
    or if there is a better ad rotate script without sql so that i can use with buzzcity,adiquity,reporo etc etc
    Thanks
    This was posted here already,
    i just can't find the topic,
    no SQL needed.
    In randAd.php
    PHP Code:
    <?
    $randDat = @file("adData.dat");
    $random_num = rand (0,count($randDat)-1);
    $udata = explode("::",$randDat[$random_num]);
    echo $udata[1];
    ?>
    and in adData.dat
    Code:
    ::ad link 1
    ::ad link 2
    ::ad link 3
    ::etc
    It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt.
    ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ !
    ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.
    キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

    Comment


      #3
      So will i just include "randad.php" in all my pages

      and put all the codes in "adData.dat"

      like so:
      PHP Code:
      :: paste buzzcity full code here
      :: paste reporo full code here
      ::etc.. 
      Thanks

      Added after 22 minutes:

      ok tested it. working perfectly with:

      Code:
      <script> example <script>
      not working with:
      (Reporo)
      Code:
      <? echo getAdMarkUP($adArraySPC['xxxx']); ?>
      Code:
      <?php include("example"); ?>
      and Buzzcity ad codes
      Last edited by brentg; 22.04.13, 17:17.

      Comment


        #4
        PHP Code:
        <?php 
        $rand 
        rand(0,100);
        if(
        $rand >=66)
        {
        //include somthing else
        //echo something else
        }
        elseif(
        $rand >=33)
        {
        //include reporo
        //echo reporo
        }
        else
        {
        //include buzzcity
        //echo buzzcity
        }
        ?>
        Advertise your mobile site for FREE with AdTwirl

        Comment


          #5
          Thanks Gumslone. Could you please share how I will integrate that into my site

          Comment


            #6
            Manged to figure it out.

            PHP Code:
             <?php 
            $rand 
            rand(0,100);
            if(
            $rand >=66)
            {
            include(
            '/ad1.php'); 
            }
            elseif(
            $rand >=33)
            {
            include(
            '/ad2.php'); 
            }
            else
            {
            include(
            '/ad3.php'); 
            }
            ?>
            @Gumslone can you perhaps say how this code work, i see its using random number.
            What does this line mean if($rand >=66) and what will happen if i change it

            Comment


              #7
              its percentage,

              first line you set random values from 0 to 100,
              if you want to show 3 different ads in random order divide 100/3 = 33.3333.. so in average from 100 page requests the ad1 will be shown 33 times, same for ad2 and ad3.

              if you want to set priority ie for ad1 50% and for ad2 and ad3 remaining 50% in equal manner you have to do like this:
              PHP Code:
              <?php  
              $rand 
              rand(0,100); 
              if(
              $rand >=50

              include(
              '/ad1.php');  

              elseif(
              $rand >=25

              include(
              '/ad2.php');  

              else 

              include(
              '/ad3.php');  

              ?>
              if you want to show 4 different ads divide 100 by 4 will be 25, so the code will look like this:
              PHP Code:
              <?php  
              $rand 
              rand(0,100); 
              if(
              $rand >=75

              include(
              '/ad1.php');  

              elseif(
              $rand >=50

              include(
              '/ad2.php');  

              elseif(
              $rand >=25

              include(
              '/ad3.php');  
              }
              else 

              include(
              '/ad4.php');  

              ?>
              actually to be more correct the rand value should start with 1 ie. $rand = rand(1,100); but it doesn't change much if you start with 0.

              PS. according to php.net mt_rand it even better than the rand function, but rand is well known and most used, so its up to you which function to use.
              Advertise your mobile site for FREE with AdTwirl

              Comment


                #8
                Awesome, understand now. Thanks so much

                PS when yo say 100 by 4 = 25% howcome your percentage in the example below is not 25% each, mistake?

                PHP Code:
                 <?php  
                $rand 
                rand(0,100); 
                if(
                $rand >=75

                include(
                '/ad1.php');  

                elseif(
                $rand >=50

                include(
                '/ad2.php');  

                elseif(
                $rand >=25

                include(
                '/ad3.php');  
                }
                else 

                include(
                '/ad4.php');  

                ?>
                Must all your percentages add up to 100% or is each $rand>= separate to the other for example one can 70 and the other 50??
                Last edited by brentg; 23.04.13, 15:01.

                Comment


                  #9
                  PHP Code:
                  <?php   
                  $rand 
                  rand(0,100);  //gives random number between 0 and 100, including 0 and 100
                  if($rand >=75)  
                  {  
                  // if the random number is larger or equal 75 show the first ad, this is 25%
                  }  
                  elseif(
                  $rand >=50)  
                  {  
                  //if number is larger or equal 50 but lover than 75, show the second ad, this is 25%
                  }  
                  elseif(
                  $rand >=25)  
                  {  
                  //if number is larger or equal 25 but lover than 50, show the third ad, this is 25%  

                  else  
                  {  
                  //if number is lover than 25, show the ad number 4, this is 25%
                  }  
                  ?>
                  you could do it also like this:
                  PHP Code:
                  <?php    
                  $rand 
                  rand(0,100);  //gives random number between 0 and 100, including 0 and 100 
                  if($rand <= 25)   
                  {   
                  // if the random number is lower than 25 show the first ad, this is 25% 
                  }   
                  elseif(
                  $rand <= 50)   
                  {   
                  //if number is lower or equal 50 but larger than 25, show the second ad, this is 25% 
                  }   
                  elseif(
                  $rand <= 75)   
                  {   
                  //if number is lower or equal 75 but larger than 50, show the third ad, this is 25%   
                  }  
                  else   
                  {   
                  //if number is larger than 75, show the ad number 4, this is 25% 
                  }   
                  ?>
                  Advertise your mobile site for FREE with AdTwirl

                  Comment


                    #10
                    That makes much more sense now. THANKS!!!

                    Just to make sure:

                    PHP Code:
                     <?php 
                    $rand 
                    rand(0,100);
                    if(
                    $rand >=45)  [B]/////// 55%[/B]
                    {
                    include(
                    'ad2.php'); 
                    }
                    elseif(
                    $rand >=20) [B]///////// 25%[/B]
                    {
                    include(
                    'ad3.php'); 
                    }
                    else                  [
                    B]////////////// 20 %[/B]
                    {
                    include(
                    'ad4.php');  
                    }
                    ?>
                    Last edited by brentg; 23.04.13, 18:59.

                    Comment


                      #11
                      yes its fine
                      Advertise your mobile site for FREE with AdTwirl

                      Comment


                        #12
                        This technique, but mostly used with mt_rand, is used in ad networks to give priorty to higer cpc/cpm and or budget ads.

                        Comment


                          #13
                          Thanks Gumslone

                          Comment

                          Working...
                          X