need assistance with php code that rotated my daily image

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dinrock
Forum Newbie
Posts: 16
Joined: Fri Feb 11, 2005 10:24 am
Location: Michigan

need assistance with php code that rotated my daily image

Post 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.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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?
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post 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.
)
Post Reply