Banner Changing script: what to do

Discussion in 'HTML & Website Design' started by BoneJj, Apr 12, 2009.

  1. #1
    alright well like the title says, I need a banner background image changing script. I tried to change one that I already had to work but for some reason I can't get it to work.

    The script uses 2 files, one is a counter and the other is the execution of the counter and all.

    here is the code for the main one:
    <?php 
    $imagepath = "http://www.floridastreetscene.com/forum/images/nexusblue/banner/fssb-bg";//where images are stored + filename w/o number 
    $sufix = ".jpg"; //sufix (usually the extension of the images) 
    $images = 3; //number of images 
    
    //---- file management stuff ---- 
    $numberfile = fopen("number.txt","r"); 
    $number=fgets($numberfile,10); 
    fclose($numberfile); 
    
    $number=$number+1; 
    if($number>$images)$number=0; 
    $numberfile = fopen("number.txt","w"); 
    fputs($numberfile,$number."\n"); 
    fclose($numberfile); 
    
    header("Cache-Control: no-cache, must-revalidate, no-store"); //force browsers to not cache it 
    header("Location: ".$imagepath.$number.$sufix); //display image 
    ?> 
    
    Code (markup):
    The second file is just a simple .txt file that is left editable on the server and this script will write it each time it's accessed and change the display image.

    Problem is that I'm trying to run it in a table "background image" code. It seems to work alright as it accesses the right image and all but I can't get it to actually change the image displayed. IDK what I'm doing wrong that it wont work.... if you have any thoughts on this or know of something better please do let me know.
     
    BoneJj, Apr 12, 2009 IP
  2. glitto

    glitto Notable Member

    Messages:
    2,839
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    205
    #2
    glitto, Apr 12, 2009 IP
  3. BoneJj

    BoneJj Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    how would I set that up to be in the background of a table though, I want the images to change behind my banner.
     
    BoneJj, Apr 12, 2009 IP
  4. glitto

    glitto Notable Member

    Messages:
    2,839
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    205
    #4
    I don't know. I just saw that script and thought it might be useful for you.
     
    glitto, Apr 12, 2009 IP
  5. leetmindz

    leetmindz Active Member

    Messages:
    155
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #5
    Yeah javascript/jquery is definitely the best way to go. Google it.
     
    leetmindz, Apr 13, 2009 IP
  6. BoneJj

    BoneJj Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I found an incredibly easy to use one:

    <script language="Javascript">
    <!--
    // original content taken from Nic's JavaScript Page with permission
    // lack of these three lines will result in copyright infringment
    // made by: Nic's JavaScript Page - http://www.javascript-page.com
    
    var currentdate = 0;
    var core = 0;
    
    function initArray() {
    
    this.length = initArray.arguments.length;
      for (var i = 0; i < this.length; i++) {
      this[i] = initArray.arguments[i];
      }
    }
    
    link = new initArray(
    "http://3bgraphics.hypermart.net/",
    "http://html.digitalsea.net/",
    "http://www.javascript-page.com/"
    );
    
    image = new initArray(
    "http://3bgraphics.hypermart.net/link/3bgraphics.gif",
    "http://html.digitalsea.net/htmlnow.gif",
    "http://www.geocities.com/~jsmaster/jsnow.gif"
    );
    
    text = new initArray(
    "3B Graphics",
    "Learn HTML in 7 Easy Steps",
    "Nic's JavaScript Page"
    );
    
    var currentdate = new Date();
    var core = currentdate.getSeconds() % image.length;
    var ranlink  = link[core];
    var ranimage = image[core];
    var rantext  = text[core];
    
    document.write('<a href=\"' +ranlink+ '\"><img src=\"'+ranimage+'\" border="0" alt=\"'+rantext+'\"></a>');
    
    //-->
    </SCRIPT>
    
    Code (markup):
    I mean how much more simple could it get?

    yeah it's random and all but still it works.
     
    BoneJj, Apr 13, 2009 IP