473,387 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

Feb 22 '07 #1
3 1773
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.dtd">
<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($myFile)); // 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

st***********@gmail.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
Feb 22 '07 #2
<comp.lang.php>
<>
<22 Feb 2007 05:55:27 -0800>
<11*********************@s48g2000cws.googlegroups. 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
http://www.yourdomain.com/cgi?=make

text file 2
images/banner_two.jpg
http://www.whatever.com/blah.html

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 .
--
www.phptakeaway.co.uk
(work in progress)
Feb 22 '07 #3
Rik
On Thu, 22 Feb 2007 14:55:27 +0100, <st***********@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
Feb 23 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: M. Clift | last post by:
Hi All, Could someone help me out with this? items = ('a', 'b', 'c', 'd') items + 1 = ( 'b', 'c', 'd', 'a') items + 2 = ( 'c', 'd', 'a', 'b') items + 3 = ( 'd', 'a', 'b', 'c') trans = 1
2
by: Kevin | last post by:
Hello all. I am new to Java script and trying to get a jpeg rotation on my website to work. I found the script here: http://www.laughland.biz/javascript.php?scid=3 I am trying to get this page...
5
by: Russell Warren | last post by:
Does anyone have an easier/faster/better way of popping from the middle of a deque than this? class mydeque(deque): def popmiddle(self, pos): self.rotate(-pos) ret = self.popleft()...
2
by: the other john | last post by:
I am looking for ideas on how to create a rollover that triggers an image rotation in another location. I know how to create a function for basic rollovers, image swapping sort of thing, but I...
1
by: number1hatfielder | last post by:
Hi there, I am trying to include some javascript in my website which rotates some stored images. I have attached the code for the index page of my website as i am having some problems getting it...
0
by: VorTechS | last post by:
I'm having a problem with an inherited label, applying text rotation to aligned text. If text rotation is applied to the aligned text, the alignment goes 'nuts'. I can find no logic to what is...
2
by: Roger Li | last post by:
I got a problem about the mean rotation calculation. I have a group of rotation matrics in my program and I want to calculate the mean rotation on the basis of these rotation matrics. I think it...
6
by: Ramtin Kazemi | last post by:
Hi How can i perform bitwise rotation in C#?
6
by: elrondrules | last post by:
I want to create a simple log rotation for the following scenario: I have a script that when executed will write debug and error messages to a specific file (say script.log). I want to create...
8
by: infoseekar | last post by:
Image Resize & Rotation Hi I have 2 scripts, one for Image rotation and other image resize and they both are working. Image resize scripts load the picture and resize it and Image rotation...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.