Page 1 of 1

need assistance with php code that rotated my daily image

Posted: Sun May 29, 2005 5:23 pm
by dinrock
Please visit my homepage to understand: http://www.danscartoons.com where that cartoon was recently being rotated by a php script. After recently redesigning my page, Frontpage had caused me to lose my php script or overwrite it via a command I inadvertently activated. The php script rotated my images every 24 hours at 2am eastern time. I am now, not sure what to do! I could use anyone's assistance, e-mail me direct if you wish as my address is on my homepage. The image source code used, was http://danscartoons.com/cotd/dailycartoon.php and I could give you my webhost's URL and my login & password if you can help me. Otherwise I would have to post a new cartoon manually, which is time consuming. I scanned 365 images into a folder that I uploaded to my web folder and then published to my web host and the php script ran things from my web server. Can anyone assist? Thanks for feedback.

Posted: Sun May 29, 2005 5:47 pm
by shiznatix
cron job may be what your looking for. or you could use a database that holds all the cartoons urls then use date() to tell the time and if the time in the database is 1 day older than the date() time then you could update the database with that days display image and then the image would be displayed.

i know i described that poorly but maybe you get the idea?

Posted: Sun May 29, 2005 10:01 pm
by JAM
Wouldn't something like this be sufficient and easier?

Code: Select all

<?php
    $number = date("z", mktime(2, 0, 0, date("m"), date("d"), date("Y")));
    echo '<img src="./images/dc'.$number.'.gif" />';
?>
Results:

Code: Select all

&lt;img src=&quote;./images/dc149.gif&quote; /&gt;
Using mktime() to easier set the date, date() to get the day of year and applying it into an image src. Requires the images to be named 1.jpg, 2.jpg, 3.jpg, 4.jpg etc. though...

(
JAM | Rearranged the code to look more like wanted in this this thread
Note that this works differently than the script(-parts) you posted in the other thread. This generates a number based on the todays date +1 hours, and puts that directly into an image html reference.
)