Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post php, javascript rotation-beginner to javascript

    I found this javascript code and want to learn more, found ajax kinda interesting too... but, with this code, I figured i could get my php banner script to rotate with seconds, instead of refresh,, well, it worked, but dont know how to get it to let me use multiple spots in one page, and not sure how its going to work with my using different size banner, and ... lol... how i can do away with the html code to view the banner, and use something different... will explain more on that later...

    when you click a banner, and hit back in the browser it say error in the bottom left corner of IE, where it would normally say "Done" for the page to be loaded,,, but seams to still work ok... my major problem is that it will only let me post this one banner at the top of my page,, If I try to make copies of it and have it load another banner it has conflicts with eachother, so until I get to learning javascript more,,, think this is out of the question... because I need to post the 120x90 ads on the right no matter what,,, on my site they are more for local ads, and its how my site is designed... hate to redesign it again...

    here the javascript, php code which is pulled by the include:

    Code:
    <script language="JavaScript">
    <!--
    var bannerArray = new Array();
    var myCount=0;
    This is the start of the php code I developed which pulles the information from a text file, and loads what I need for the banners. it also calculates how many monthes the banner spot was purchased, monthly because I dont like dealing with impressions, views or whatever,, just pay monthly, easy, fast, and other people know what they get if they are not used to advertising on the internet....

    PHP Code:
    <?php

    $fd 
    =fopen ($_REQUEST[s].".txt""r");
    if (
    $fd)
    {
    $line null;
    while (!
    feof ($fd)) 
    {
    if (!
    $line)
    {
    // Skip header I skip one line of the text file, so the text file has how to input the information into the text file, want to make administration script later,, might want mysql later too.. but text file is how I started with...

    PHP Code:
    $line fgets($fd4096);
    }
    else
    {
    $line fgets($fd4096);
    if (
    strlen($line) > 10)
    {
    list(
    $id,$d_start,$dur,$url,$ban,$alt,$tar,$c_name,$c_email,$c_phone) = split (","$line9);
    list(
    $m,$d,$y)= split ("\/"$d_start3);
    list(
    $dd,$mm,$yyyy) = split("-",date("d-m-Y",time()));
    $today mktime(000$mm$dd$yyyy);

    $d_end mktime(000$m+$dur$d$y);
    $ds date('m/d/Y',$d_end);
    if(
    $d_end >= $today){
    $c count($line);
    for(
    $i=0;$i<$c;$i++){
    echo 
    "bannerArray[$id] = \"<A HREF='".$url."' target='".$tar."'><IMG SRC='".$ban."' border='0' alt='".$alt."'></A>\";\n";
    }}}}}

    fclose($fd);
    }
    ?> 
    and back to the javascript I borrowed...
    Code:
    bannerRotate();
    
    function bannerRotate() {
    
    if(myCount > bannerArray.length-1){myCount=0;}
    
    if (document.all){
    document.all.l3.innerHTML=bannerArray[myCount];
    }
    
    else if (document.layers){
    
    document.layers.l1.document.layers.l2.document.open();
    document.layers.l1.document.layers.l2.document.write(bannerArray[myCount]);
    document.layers.l1.document.layers.l2.document.close();
    }
    setTimeout("bannerRotate()", 3000);
    myCount++;
    }
    // -->
    </script>
    Then I have to use this above the include,, because not my code,,, to place in the html.. I dont like using this, and if possible would like to change,,, maybe use something like <div id=banner s=728x90></div>
    Code:
    <font face="Tahoma" size="2">
    <ilayer id="l1"></p>
    <layer id="l2">
    <div id="l1">
    <div id="l3" style="position:relative">
    </div>
    </div>
    </layer>
    </ilayer>
    </font>
    is there any suggestions on how I can do this, or someone might be able to tell me where I can get a better, shorter javascript to use,, because the only reason I want the javascript is to rotate the ads in seconds, and be able to place more than one banner on a single page... kinda like this:

    Code:
    <table border="0" cellpadding="0" cellspacing="0" width="100%" height="90"><tr><td align="center" valign="bottom">
    
     <div id=banner s=120x90></div>
    </td><td align="center" valign="middle">
    
    <div id=banner s=728x90></div>
    </td><td align="center" valign="bottom">
    
    <div id=banner s=120x90></div>
    
    </td></tr></table>
    right now dont really have time to learn,, Im willing to redew all the javascript altogether, but the php ive come kinda stuck with,,, kinda hard to recode that...but have to get this script up as soon as possible, but want to learn more because found many things while searching on this feature Id like to try with my php script to make them a lil better,,, and want to learn more about this ajax because now there is another system out there to integrate it more with php... Provides PHP and JavaScript libraries for performing AJAX,,, which sounded interesting, and have it on my home server, now, just cant explain much about it yet...lol
    thanks..

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    "If I try to make copies of it and have it load another banner it has conflicts with each other"

    This is a clunky way to do it, and your code is pretty ancient, but you can rename all functions and variables to avoid conflicts e.g.

    var bannerArray1
    var bannerArray2
    var myCount1
    var myCount2

    function bannerRotate1()
    function bannerRotate2()

    But who wants to visit a site stuffed with banners???

  • #3
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    so whats clunky, the javascript? lol... the php is my own,,, its all I know,, course ive been working with php for almost 5 years,, and have been out of it for almost 1 year until recently since about a month ago...

    thanks for the input,, tell me,, what would you change,, I just want something right now to post on the site, want to redew it later to try to tighten it up, hopefully make it all work with one script, and turn it into mysql, and a good administration system...

    a site stuffed with banners,,, well,, let me put it this way,, the site is for a local community that has so many business's, and more information for the community to deal with things,,, like free classifieds, and such,,, the advertising is only their to make revenue until we can find a better way,,, the main thing is that with everything they are going to get for free with the site,, dont think they will even look at the banners anyhow,, but all business's advertising are local where people shop anyhow... like the local food stores... clothing stores,, and hope to get local advertising for events, car shows, and entertainment like bands playing at certain clubs... but if no site plastered with banners,, then no site..
    how else to keep it up? and that is a legit question,, any suggestions,, great,,, cuz i need them,,, the main thing is, wanted to keep as much as possible free for the visitors...
    Last edited by spidermonster; 12-10-2006 at 05:02 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
    •