Ad rotation on a website

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • stephenmarron@gmail.com

    Ad rotation on a website

    Hi Everyone,

    I am having trouble looking for a script that will rotate images from
    a standard text file.

    I have a folder set up with two images that rotate every time the page
    is refreshed. They also have a hyperlink so that when an image/ad is
    clicked on it goes to the advertiserments web address.
    The only problem is that the path to the images and corresponding
    hyperlink are in a javascript file.

    Is it possible to reference them from a standard text file so that a
    non-techie can login to webedit pro and edit the image name and url
    everytime the ad is being changed ?

    The script can be java scrip or preferably PHP, once it can reference
    a .txt file...Im happy

    Any help would be very much appreciated...

    Stephen

  • Vincent

    #2
    Re: Ad rotation on a website

    photo.txt

    one.jpg,http://www.enemy.be,two.jpg,http://www.tuinwijk32.be


    index.php (in same dir as pictures and textfile)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>read file</title>
    </head>

    <body>
    <?php
    $i = 0; // counter
    $myFile = "photo.txt" ; // file to read
    $fh = fopen($myFile, 'r'); // open file to read
    $theData = fread($fh, filesize($myFil e)); // read the complete file
    fclose($fh); // close connection to file
    $part1 = split(",", $theData); // split at comma

    foreach($part1 as $waarde) {
    $kolom[$i] = $waarde; // put data in array ($kolom)
    $i++; // counter = counter++
    }
    // $kolom[0] = foto1.jpg - $kolom[2] = foto2.jpg
    $getal = ((rand(1, 2))%2 == 0) ? 0 : 2; // randomize
    echo("<a href=\"" . $kolom[$getal + 1] . "\"><img src=\"" .
    $kolom[$getal] . "\" alt=\"" . $kolom[$getal] . "\"></a>");
    ?>
    </body>
    </html>

    Hope this helps

    stephenmarron@g mail.com schreef:
    Hi Everyone,
    >
    I am having trouble looking for a script that will rotate images from
    a standard text file.
    >
    I have a folder set up with two images that rotate every time the page
    is refreshed. They also have a hyperlink so that when an image/ad is
    clicked on it goes to the advertiserments web address.
    The only problem is that the path to the images and corresponding
    hyperlink are in a javascript file.
    >
    Is it possible to reference them from a standard text file so that a
    non-techie can login to webedit pro and edit the image name and url
    everytime the ad is being changed ?
    >
    The script can be java scrip or preferably PHP, once it can reference
    a .txt file...Im happy
    >
    Any help would be very much appreciated...
    >
    Stephen
    >

    Comment

    • Krustov

      #3
      Re: Ad rotation on a website

      <comp.lang.ph p>
      <>
      <22 Feb 2007 05:55:27 -0800>
      <1172152527.838 122.65930@s48g2 000cws.googlegr oups.com>
      Is it possible to reference them from a standard text file so that a
      non-techie can login to webedit pro and edit the image name and url
      everytime the ad is being changed ?
      >
      The script can be java scrip or preferably PHP, once it can reference
      a .txt file...Im happy
      >
      It would be quite easy to write a small script that would let you
      add/edit the 2 line text file for each rotating banner .

      text file 1
      images/banner_one.jpg


      text file 2
      images/banner_two.jpg


      On your actual webpage that uses them - its just a matter of generating
      a random number in order to display the banner and use the url that
      accompanys it .

      Assuming you have 10 banners you want to rotate .....

      rnd=(10)

      Assuming the above picks 4 as the random number .....

      file="banners/4.txt";
      read line 1
      read line 2

      <divhref=url image </div>

      I suppose you dont really need to write a suitable script in you create
      the text files offline and upload & for the most part you would only
      really need to generate a random number and read the 2 lines of text to
      be used .


      --

      (work in progress)

      Comment

      • Rik

        #4
        Re: Ad rotation on a website

        On Thu, 22 Feb 2007 14:55:27 +0100, <stephenmarron@ gmail.comwrote:
        Hi Everyone,
        >
        I am having trouble looking for a script that will rotate images from
        a standard text file.
        >
        I have a folder set up with two images that rotate every time the page
        is refreshed. They also have a hyperlink so that when an image/ad is
        clicked on it goes to the advertiserments web address.
        The only problem is that the path to the images and corresponding
        hyperlink are in a javascript file.
        >
        Is it possible to reference them from a standard text file so that a
        non-techie can login to webedit pro and edit the image name and url
        everytime the ad is being changed ?
        >
        The script can be java scrip or preferably PHP, once it can reference
        a .txt file...Im happy
        >
        Any help would be very much appreciated...

        Check out fgetcsv(), and possibly fputcsv() if you want to make an
        interface to it later.
        --
        Rik Wasmus

        Comment

        Working...