How to rotation ads script ?

Discussion in 'PHP' started by Fififa, Mar 23, 2009.

  1. #1
    Hello,

    I want to show my ads rotationly between two ads . How to do it with php ?

    Ex : This is my two ads code
    <script language="javascript">
    document.write('<iframe src="http://newt1.adultadworld.com/jsc/z5/ff2.html?n=607;c=2457;s=13527;w=468;h=60;p=13527" frameborder=0 marginheight=0 marginwidth=0 scrolling="no" allowTransparency="true" width=468 height=60></iframe>');
    </script>
    PHP:
    And
    <script language="javascript">
    document.write('<iframe src="http://newt1.adultadworld.com/jsc/z5/ff2.html?n=607;c=2457;s=13527;d=14;w=728;h=90;p=13527" frameborder=0 marginheight=0 marginwidth=0 scrolling="no" allowTransparency="true" width=728 height=90></iframe>');
    </script>
    PHP:
    I only want one of them will be displayed on my page.

    PLease Help me !
     
    Fififa, Mar 23, 2009 IP
  2. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #2
    switch (rand(1, 2))
    {
       case 1:
          echo "Ad 1 code";
          break;
       case 2:
          echo "Ad 2 code";
          break;
    }
    Code (markup):
     
    SmallPotatoes, Mar 23, 2009 IP
  3. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #3
    crivion, Mar 23, 2009 IP
  4. lopy_is_me

    lopy_is_me Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    How can I dot it with php and xml together ????
     
    lopy_is_me, Mar 23, 2009 IP
  5. Fififa

    Fififa Peon

    Messages:
    152
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Fififa, Mar 23, 2009 IP
  6. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #6
    yes you can, try it, but you need to take care at quotes there are some rules on php
     
    crivion, Mar 23, 2009 IP
  7. Fififa

    Fififa Peon

    Messages:
    152
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    it now work now :(, anyone please help me
     
    Fififa, Mar 24, 2009 IP
  8. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #8
    copy paste here exactly how you done it
     
    crivion, Mar 24, 2009 IP
  9. Ilyesoft

    Ilyesoft Banned

    Messages:
    164
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    You can use random in php, right ?
     
    Ilyesoft, Mar 25, 2009 IP
  10. skyfe

    skyfe Active Member

    Messages:
    256
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    63
    #10
    You could do this with PHP if that's what you want:

    
    <?php
    
    //just some example
    $ads = 5; //amount of ads codes that can be shown
    $ad_show = mt_rand(1,$ads); //generate random ad ID
    
    switch($ad_show) {
    
       case '1':
       //show code of ad 1
       break;
    
       case '2':
       //show code of ad 2
       break;
    
       //... etc etc
    
    }
    
    ?>
    
    Code (markup):
    Just an example, if that's what you mean. Could also be done with a database containing all codes for example, with all unique IDs then let it get a random ID and show the code belonging to that ID.

    Skyfe.
     
    skyfe, Mar 25, 2009 IP