i am searching for sricpt witch changes picture every day. i searched and found just these which changes pics on every refresh. waiting for help. ( it can be php script or javascript)
day image
Do you want the pics to be changed every day of the week, every day of the month or just random?
How many images do you have?
How many images do you have?
i would like it would change once a week. i have about 20 images now.
you could do something like this:
I didn't have the time to test it. So please tell me if it doesn't work
Grtz.
| Code: |
|
<? $a = 20; // Number of images should be named img1.jpg till img20.jpg ?> <a href="img<? echo (string) date("W")%$i; ?>.jpg |
I didn't have the time to test it. So please tell me if it doesn't work
Grtz.
doesnt work. i tried to change to
but this also didnt help
| Code: |
| <? $a = 20; // Number of images should be named img1.jpg till img20.jpg?>
<a href="img<? echo (string) date("W")%$i; ?>.jpg"> |
but this also didnt help
Hey, try using $a instead of $i in the second line. Keep track of your variables
Oh, and your ?> is commented now, so the parser won't see it and think your link is php too.
Also use <?php instead of <?, this to avoid confusion with xml...
BlackSkad
Oh, and your ?> is commented now, so the parser won't see it and think your link is php too.
Also use <?php instead of <?, this to avoid confusion with xml...
BlackSkad
doesnt work
sorry for waiting so long
Try searching in dynamicdrive.com there are lot of scripts that
could be found from there.
could be found from there.
Ok, try this. Create one new folder and put inside rotator.php and day.txt. Also put in this folder subfolder images. Rename your images like 1-anything.jpg, 2-anything.gif, 3-anything.png, etc. Only numbers is important. In day.txt type any number less then 26 and image name one before you want to see next tomorrow. Then include rotator.php on your PHP page. I hope so it will work. Sorry, I haven't time for better explain.
rotator.php
day.txt
rotator.php
| Code: |
| <?php
$day = date("z"); // day in year $file = file("day.txt"); list($oldDay, $oldImage) = explode("|", $file[0]); list($num, $image) = explode("-", $oldImage); $dir = "images"; // check old and new day if($day != $oldDay) { // open and read image folder $openDir = opendir($dir); while (false !== ($fileNames = readdir($openDir))) { $allfiles[] = $fileNames; } // kick out anything what is not file for($o = 0; $o < count($allfiles); $o++) { list($front, $ext) = explode(".", $allfiles[$o]); if($front == "" || $ext == "") { continue; } else { $images[] = $allfiles[$o]; } } asort($images, SORT_NUMERIC); $sortImages = array_values($images); $count = count($sortImages); for($i = 0; $i < $count; $i++) { if (strpos($sortImages[$i], $image) > 0 && $i < $count-1) { $newImage = $sortImages[$i+1]; break; } else { $newImage = $sortImages[0]; } } // write new data in day.txt $newData = $day . "|" . $newImage; $fileNew = fopen("day.txt", "wb"); fwrite($fileNew, $newData); fclose($fileNew); $display = include_once("$dir/$newImage"); } else { $display = include_once("$dir/$oldImage"); } echo $display; ?> |
day.txt
| Code: |
| 25|1-example.jpg |
