|
Posted by Vincent on 02/22/07 17:12
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
stephenmarron@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
>
Navigation:
[Reply to this message]
|