Image rotation PHP script needs a tweak
This is what I want to do: I want a sidebar image rotation of a different image each day of the month, clicking through to different sponsor for each image. I found a PHP script that does the random image each day part, but I can't figure out how to include the link code for each image. Here is the script that works so far, and if anybody can show me how to put in the URL for each image to link to, I will be so happy! I've put in 2 images to test it. There will be up to 30 eventually. These are pictures of homes for sale, each one linking to an individual real estate agent's website. I tried sticking the URL right after the image code, but that made the whole thing break.
Code:
<?php |
Paulae,
What you need to do is put the links in an array also. Try this HTML Code:
<?php |
Thanks. But that didn't do the trick. At first, I pasted in just what you gave me, and the image disappeared. Then I noticed the
Code:
); This is what's there now: Code:
<?php |
Paulae,
I found another typo, the second array is '$linkOfTheFDay'. Get rid of the extra 'F', sigh the problems you get when you don't have your first cup of coffee. Here is the updated version HTML Code:
<?php |
Almost there! By "extra echo statements," you mean which ones?
http://www.larchmontgazette.com Scroll to the very bottom of the right sidebar. Image is there, link works. Part of the code is showing. I'm not sure which part to comment out. |
These three lines
echo "potd=" . $photoOfTheDay[$x] . "<br>"; echo "lotd=" . $linkOfTheDay[$x] . "<br>"; echo "x=" . $x . "<br>"; were just for displaying the variables so I/(you) would know it was working. You probably want to change the last line from: echo "<<<EOC <center> " . $ad_image . " </center> EOC" ; to echo "<center> " . $ad_image . " </center>" ; I thought the <<<EOC was something related to a plugin or something |
OK, that did the trick!
Oddly enough, though, and I don't think this has a thing to do with your work, the image has changed back today to the one from yesterday. It's rotating images more than once a day. Can you see anything in the code that would explain it? |
The way the code is written, it gets todays DAY, today is the 14th. It then checks to see if the array has 14 or more images (it doesn't, there are only 2) so it picks a random image from teh array and displays it.
You need an image for the 1st an image for the 2nd ... an image for the 31st then it will stay with that image all day |
Ah. OK. I'll try putting more images in there.
By the way, I made a donation specifically to you. Thanks for the help! |
You're welcome and thanks for the donation!
|
All times are GMT -6. The time now is 02:11 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.