1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need PHP Add Rotator Script!

Discussion in 'Scripts' started by Omar, Jan 27, 2006.

  1. #1
    Dear Friends,

    I need some help about Random Ads Rotation..

    Actually I need a “PHP Random Add Rotator Script” for my Site… A Script that should work with out MY SQL…. And maximum numbers of Adds should be randomly rotated in that script.

    I am waiting

    Regards

    Omar
    (www.pakdes.com)
     
    Omar, Jan 27, 2006 IP
  2. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    $Ad[0] = '<a href="http://www.site.com" TARGET="_blank">Site 0</a>';
    $Ad[1] = '<a href="http://www.site1.com" TARGET="_blank">Site 1</a>';
    $Ad[2] = '<a href="http://www.site2.com" TARGET="_blank">Site 2</a>';    
        
    $Weight[0]=3;
    $Weight[1]=3;
    $Weight[2]=3;
    
           
        $sum =0;
        for($i=0;$i<count($Weight);$i++)
        	$sum+=$Weight[$i];
        $ShowAd = rand(0, $sum - 1);
        for($i=0;$i<count($Weight);$i++)
        {
        	if($ShowAd<=$Weight[$i])
        	{
        		$ShowAd=$i;
        		break;
        	}
        	else
        		$ShowAd-=$Weight[$i];
        }
        echo $Ad[$ShowAd];
    
    PHP:
     
    dave487, Jan 27, 2006 IP
  3. Cristian Mezei

    Cristian Mezei Notable Member

    Messages:
    3,332
    Likes Received:
    355
    Best Answers:
    0
    Trophy Points:
    213
    #3
    I used, and will always use for my ad management, the best.
     
    Cristian Mezei, Jan 27, 2006 IP
    stuw likes this.
  4. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #4
    There are far more advanced systems than my script but if you just want to display adverts and maybe display some more than others without using a database or tracking views or clicks then this is all you need.
     
    dave487, Jan 27, 2006 IP
  5. Omar

    Omar Peon

    Messages:
    70
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for this CODE, tell me one thing.. that should a add the "Add Code" in Ad[0], Ad[1], Ad[2]?? Or I can add more then 3 Ads? If so tell me HOW? Lets suppose I want to insert 10 Ads in this code then?

    Waiting
     
    Omar, Jan 27, 2006 IP
  6. stuw

    stuw Peon

    Messages:
    702
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #6
    looks like you keep adding
    $Ad[x] = '<a href="http://www.site2.com" TARGET="_blank">Site 2</a>';
    and
    $Weight[x]=3;
    until you get to 10
     
    stuw, Jan 27, 2006 IP
  7. Omar

    Omar Peon

    Messages:
    70
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Dear this script is not working............. please chekc this out
     
    Omar, Jan 27, 2006 IP
  8. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Make sure if you add more adverts you specify the weight of the adverts as well eg

    
    $Ad[0] = '<a href="http://www.site.com" TARGET="_blank">Site 0</a>';
    $Ad[1] = '<a href="http://www.site1.com" TARGET="_blank">Site 1</a>';
    $Ad[2]= '<a href="http://www.site2.com" TARGET="_blank">Site2</a>';        
    $Ad[3]= '<a href="http://www.site2.com" TARGET="_blank">Site2</a>';
    $Weight[0]=3;
    $Weight[1]=3;
    $Weight[2]=3;
    $Weight[3]=3;
    
    PHP:
    etc.

    If you are still having problems post your source code.
     
    dave487, Jan 28, 2006 IP
  9. NikkiBlue

    NikkiBlue Well-Known Member

    Messages:
    188
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    140
    #9
    Thanks for sharing this Dave!
     
    NikkiBlue, Jan 31, 2006 IP
  10. Omar

    Omar Peon

    Messages:
    70
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Dear Really its not working.. Ihave tried many times but not working yet... can you check by your self?

    Okay let me give u the code of 2 Diff Adv.

    1 is :+++++++++++++++++++++++++++++++++++++++++++
    <!--- start of focusIN code --->
    <script language="JavaScript">
    <!--
    var now = new Date();
    var uaid = now.getTime() % Math.floor(8640000 - Math.random()*1000);
    document.write('<scr'+'ipt src="http://focusin.ads.targetnet.com//ad/id=pakdes.com&opt=hjj&rw=468&rh=60&urlid=1&cv=220&uid=' + uaid + '" ></scr'+'ipt>');
    //-->
    </script>
    <noscript>
    <iframe allowTransparency="true" src="http://focusin.ads.targetnet.com//ad/id=pakdes.com&opt=hhn&rw=468&rh=60&urlid=1&cv=220&uid=1" width=468 height=60 frameborder=0 marginheight=0 marginwidth=0 scrolling="no">
    <a href="http://focusin.ads.targetnet.com//ad/id=pakdes.com&opt=cin&rw=468&rh=60&urlid=1&cv=220&uid=1" target="_top"><img
    src="http://focusin.ads.targetnet.com//ad/id=pakdes.com&opt=hin&rw=468&rh=60&urlid=1&cv=220&uid=1" alt="Click here to visit our sponsor" width=468 height=60 border=0></a>
    </iframe>
    </noscript>
    <!--- end of focusIN code --->
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    2nd is++++++++++++++++++++++++++++++++++++++++++++++++++++
    <!-- PRECISIONCLICK.COM 2006 (C) -->
    <!-- Ad Format: 468x60 -->
    <script language="javascript"><!--
    var d=new Date();var ccb=(d.getTime()%8673806982)+Math.random();document.write('<scr'+'ipt language="javascript" src="http://servedby.precisionclick.com/midas/?src=pub&site=417&adfmt=6&ccb='+ccb+'"></scr'+'ipt>');
    //--></script><noscript><iframe src=src="http://servedby.precisionclick.com/midas/?typ=1&pub=1&site=417&adfmt=6" width="468" height="60" marginwidth="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe></noscript>
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++

    Now please creat a PROOF of Rendom Rotation of Above TWO AD CODES...

    Waiting

    Regards
     
    Omar, Feb 3, 2006 IP
  11. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #11
    
    <?php
    
            
    $Weight[0]=3;
    $Weight[1]=3;
                
    $sum =0;    
    for($i=0;$i<count($Weight);$i++)        
    $sum+=$Weight[$i];    
    $ShowAd = rand(0, $sum - 1);    
    for($i=0;$i<count($Weight);$i++)    {        
    	
    	if($ShowAd<=$Weight[$i])        {            
    		$ShowAd=$i;            
    	break;        }       
    	 else            
    	$ShowAd-=$Weight[$i];    }    
    	
    		
    	if($ShowAd=="1"){
    	
    	?>
    
    	?><!--- start of focusIN code --->
    <script language="JavaScript">
    <!--
    var now = new Date();
    var uaid = now.getTime() % Math.floor(8640000 - Math.random()*1000);
    document.write('<scr'+'ipt src="http://focusin.ads.targetnet.com//ad/id=pakdes.com&opt=hjj&rw=468&rh=60&urlid=1&cv=220&uid=' + uaid + '" ></scr'+'ipt>');
    //-->
    </script>
    <noscript>
    <iframe allowTransparency="true" src="http://focusin.ads.targetnet.com//ad/id=pakdes.com&opt=hhn&rw=468&rh=60&urlid=1&cv=220&uid=1" width=468 height=60 frameborder=0 marginheight=0 marginwidth=0 scrolling="no">
    <a href="http://focusin.ads.targetnet.com//ad/id=pakdes.com&opt=cin&rw=468&rh=60&urlid=1&cv=220&uid=1" target="_top"><img 
    src="http://focusin.ads.targetnet.com//ad/id=pakdes.com&opt=hin&rw=468&rh=60&urlid=1&cv=220&uid=1" alt="Click here to visit our sponsor" width=468 height=60 border=0></a>
    </iframe>
    </noscript>
    <?php
    }
    elseif($ShowAd=="2")
    {
    ?>
    
    <!-- PRECISIONCLICK.COM 2006 (C) -->
    <!-- Ad Format: 468x60 -->
    <script language="javascript"><!--
    var d=new Date();var ccb=(d.getTime()%8673806982)+Math.random();document.write('<scr'+'ipt language="javascript" src="http://servedby.precisionclick.com/midas/?src=pub&site=417&adfmt=6&ccb='+ccb+'"></scr'+'ipt>');
    //--></script><noscript><iframe src=src="http://servedby.precisionclick.com/midas/?typ=1&pub=1&site=417&adfmt=6" width="468" height="60" marginwidth="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe></noscript>
    
    <?php
    }
    else
    {
    	
    }
    ?>
    
    PHP:
     
    dave487, Feb 3, 2006 IP
  12. Omar

    Omar Peon

    Messages:
    70
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Dear DAV nice effort but its not workinng... please check it by ur self, have u checked before pasting here?
     
    Omar, Feb 3, 2006 IP
  13. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #13
    
    <?php
    
            
    $Ad[0] =1;
    $Ad[1] =2;
      
    
    $Weight[0]=3;
    $Weight[1]=3;
    ;            
    $sum =0;    for($i=0;$i<count($Weight);$i++)        
    $sum+=$Weight[$i];    $ShowAd = rand(0, $sum - 1);    
    for($i=0;$i<count($Weight);$i++)    {        
    	if($ShowAd<=$Weight[$i])        
    {            
    	$ShowAd=$i;            break;        }        else            
    	$ShowAd-=$Weight[$i];    }    
    	
    	
    	if($Ad[$ShowAd]=="1"){
    		
    	
    	?>
    
    	<!--- start of focusIN code --->
    <script language="JavaScript">
    <!--
    var now = new Date();
    var uaid = now.getTime() % Math.floor(8640000 - Math.random()*1000);
    document.write('<scr'+'ipt src="http://focusin.ads.targetnet.com//ad/id=pakdes.com&opt=hjj&rw=468&rh=60&urlid=1&cv=220&uid=' + uaid + '" ></scr'+'ipt>');
    //-->
    </script>
    <noscript>
    <iframe allowTransparency="true" src="http://focusin.ads.targetnet.com//ad/id=pakdes.com&opt=hhn&rw=468&rh=60&urlid=1&cv=220&uid=1" width=468 height=60 frameborder=0 marginheight=0 marginwidth=0 scrolling="no">
    <a href="http://focusin.ads.targetnet.com//ad/id=pakdes.com&opt=cin&rw=468&rh=60&urlid=1&cv=220&uid=1" target="_top"><img 
    src="http://focusin.ads.targetnet.com//ad/id=pakdes.com&opt=hin&rw=468&rh=60&urlid=1&cv=220&uid=1" alt="Click here to visit our sponsor" width=468 height=60 border=0></a>
    </iframe>
    </noscript>
    <?php
    
    }
    else
    {
    	
    ?>
    
    <!-- PRECISIONCLICK.COM 2006 (C) -->
    <!-- Ad Format: 468x60 -->
    <script language="javascript"><!--
    var d=new Date();var ccb=(d.getTime()%8673806982)+Math.random();document.write('<scr'+'ipt language="javascript" src="http://servedby.precisionclick.com/midas/?src=pub&site=417&adfmt=6&ccb='+ccb+'"></scr'+'ipt>');
    //--></script><noscript><iframe src=src="http://servedby.precisionclick.com/midas/?typ=1&pub=1&site=417&adfmt=6" width="468" height="60" marginwidth="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe></noscript>
    
    <?php
    
    }
    
    ?>
    
    PHP:
    Here you go, fully tested. Let me know your paypal address so I can send the bill..........;)
     
    dave487, Feb 3, 2006 IP
  14. Omar

    Omar Peon

    Messages:
    70
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Sir GGGGGGGGGGGGGGGGGG, its not workiinnnnnnnnnngggggggggggggggggggg......... I think 1st I have to pay then it'll be avaialable:p

    Dear check it again!! Nothing is available in DISPLAY!!
     
    Omar, Feb 3, 2006 IP
  15. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #15
    There is nothing wrong with the php code (tested it first) so the only problem could be with the JS maybe.

    Try replacing the 2 adverts with text saying "Advert 1" and "Advert 2" and let me know what you get.

    Are you putting the code in a proper page or just using the script on its own?
     
    dave487, Feb 3, 2006 IP
  16. Omar

    Omar Peon

    Messages:
    70
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Dear Dav,

    I have checked it by replacing some thing like..... ABCD (Replacing 1st Ad Code) and EFGH (by replacing 2nd Ad Code) by replacing with these TAXT WORDS, its really working!!! without any trouble, but when I pust AD CODES into this script as you PUT my given CODES, its not working!!

    It is not possible if we save these code in different HTML Files & we should put only FILE NAME i.e "ABC_CODE.HTML" and this code pick AD CODE from those files?

    Is it possible?

    Regards & once again really I am very thankful for all these efforts for me
     
    Omar, Feb 3, 2006 IP
  17. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #17
    There must be a problem with the adverts you are including I think.

    Try putting each advert on its own in the page instead of using the script to see what the problem is.
     
    dave487, Feb 4, 2006 IP
  18. Omar

    Omar Peon

    Messages:
    70
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #18
    Dear Dav, I have checked these ADD CODES on my site...

    you can check this site : www.pakdes.com / www.pakdes.com/forum

    It will work if we include any HTML File?

    Regards
     
    Omar, Feb 5, 2006 IP
  19. fsmedia

    fsmedia Prominent Member

    Messages:
    5,163
    Likes Received:
    262
    Best Answers:
    0
    Trophy Points:
    390
    #19
    If you liked PAN, you will like Max Media Manager even more! Both require MySQL, but it's worth it if you can find a database somewhere.
     
    fsmedia, Feb 5, 2006 IP
  20. mrongey

    mrongey Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #20
    I too am having problems. Maybe its something really obvious that I am missing because I am a newbie.

    Here is the code for my webpage:

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    
    <?php
    
          $Ad[0] = '<a href="http://www.site.com" TARGET="_blank">Site 0</a>';
          $Ad[1] = '<a href="http://www.site1.com" TARGET="_blank">Site 1</a>';
          $Ad[2] = '<a href="http://www.site2.com" TARGET="_blank">Site 2</a>';   
             
          $Weight[0]=3;
          $Weight[1]=3;
          $Weight[2]=3;
           
                 
              $sum =0;
              for($i=0;$i<count($Weight);$i++)
                  $sum+=$Weight[$i];
              $ShowAd = rand(0, $sum - 1);
              for($i=0;$i<count($Weight);$i++)
              {
                  if($ShowAd<=$Weight[$i])
                  {
                      $ShowAd=$i;
                      break;
                  }
                  else
                      $ShowAd-=$Weight[$i];
              }
              echo $Ad[$ShowAd]; 
    		  
    ?>
    </body>
    </html>
    
    HTML:
    And all I get is a blank page.

    Here's the page: http://www.yes2.us/Untitled-2.htm

    Maybe I shaould start a new topic for this, but, if I can get this to work, I would like to use it to randomly redirect to different weblinks, but I'm not sure how to modify it to do that.
     
    mrongey, Feb 9, 2006 IP