beetle08 Posted June 17, 2010 Share Posted June 17, 2010 hi, im just starting out to understand the different types of scripting languages so at the moment I don’t know how to script, but im pretty sure what I want is writing in php. the thing that I want is some kind countdown which is from play.com, for a webpage. I originally thought it was a proper countdown with the digits changing, but later on I noticed that it was an image changing. If you can have a look at it on the website, play.com, I’d really appreciate it, as I might be wrong. im pretty sure it’s not been created in Javascript, as its not animated. And that you need to refresh the page for the image to change. My question is, do you also think that they've created this in php, that will replace the existing image (in this case, the 18 days left image) to a different image (like 17 days left image) every 24 hours? Thanks Link to comment https://forums.phpfreaks.com/topic/205058-changing-a-current-image-to-a-different-image-every-24-hours/ Share on other sites More sharing options...
vbnullchar Posted June 17, 2010 Share Posted June 17, 2010 this is made with php, you need to set the end time then subtract it from the current. example the difference is 25 days.. just use the 25th image http://images.play.com/SiteCSS/Play/Live2/2010051801/img/countdown/25.gif Link to comment https://forums.phpfreaks.com/topic/205058-changing-a-current-image-to-a-different-image-every-24-hours/#findComment-1073420 Share on other sites More sharing options...
beetle08 Posted June 17, 2010 Author Share Posted June 17, 2010 excellent, thanks. do you know where i can find this type php script? ,thanks Link to comment https://forums.phpfreaks.com/topic/205058-changing-a-current-image-to-a-different-image-every-24-hours/#findComment-1073442 Share on other sites More sharing options...
jonsjava Posted June 17, 2010 Share Posted June 17, 2010 here's a sample of what you can do. Simple, quick, dirty, but it should work. If you need help understanding anything, let us know. <?php $image_dir = "images/countdown"; $day = 31; // Day of the countdown $month = 12; // Month of the countdown $year = 2010; // Year of the countdown $hour = 23; // Hour of the day (east coast time) $event = "New Year's Eve, 2010"; //event $calculation = ((mktime ($hour,0,0,$month,$day,$year) - time(void))/3600); $days = (int)($hours/24); $image = $image_dir."/$days.gif"; //assuming the image set is gif, and you have them named 1.gif, 2.gif, 3.gif, etc. echo "<img src='$image'>"; ?> Link to comment https://forums.phpfreaks.com/topic/205058-changing-a-current-image-to-a-different-image-every-24-hours/#findComment-1073446 Share on other sites More sharing options...
jonsjava Posted June 17, 2010 Share Posted June 17, 2010 bad code in my last example. That's what I get for using untested code. <?php $image_dir = "images/countdown"; function countdown($month,$day,$year) { // subtract desired date from current date and give an answer in terms of days $remain = ceil((mktime(0,0,0,$month,$day,$year) - time()) / 86400); // show the number of days left if ($remain > 0) { return $remain; } // if the event has arrived, say so! else { return "arrived"; } } $days = countdown(7,11,2010); $image = $image_dir."/$days.gif"; //assuming the image set is gif, and you have them named 1.gif, 2.gif, 3.gif,... and one for arrived.gif echo "<img src='$image'>"; ?> Link to comment https://forums.phpfreaks.com/topic/205058-changing-a-current-image-to-a-different-image-every-24-hours/#findComment-1073454 Share on other sites More sharing options...
beetle08 Posted June 17, 2010 Author Share Posted June 17, 2010 here's a sample of what you can do. Simple, quick, dirty, but it should work. If you need help understanding anything, let us know. thats great, i'll check it out. just one thing, how do you apply this php code into dreamweaver? also where does the code get the curent time from? do i input it into the php, or is it getting the time from the pc clock ,thanks Link to comment https://forums.phpfreaks.com/topic/205058-changing-a-current-image-to-a-different-image-every-24-hours/#findComment-1073464 Share on other sites More sharing options...
jonsjava Posted June 17, 2010 Share Posted June 17, 2010 as far as dream weaver -- don't know. Haven't used it in years. Vim is my friend about the time: PHP gets the time from the server. Link to comment https://forums.phpfreaks.com/topic/205058-changing-a-current-image-to-a-different-image-every-24-hours/#findComment-1073468 Share on other sites More sharing options...
beetle08 Posted June 17, 2010 Author Share Posted June 17, 2010 as far as dream weaver -- don't know. Haven't used it in years. Vim is my friend about the time: PHP gets the time from the server. excellent, thanks Link to comment https://forums.phpfreaks.com/topic/205058-changing-a-current-image-to-a-different-image-every-24-hours/#findComment-1073477 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.