byrne86 Posted October 26, 2010 Share Posted October 26, 2010 Hi, I haven't used any php for a while, but i am making a website, and i need some advice on how to do the following: I want the website to change an image once every 24 hours, the image will revert back to the original image after 2 minutes. Does anyone have an idea how I could start doing this? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 26, 2010 Share Posted October 26, 2010 So, for example, you want to display image #1 from noon to 12:02, and image #2 at all other times? Quote Link to comment Share on other sites More sharing options...
byrne86 Posted October 26, 2010 Author Share Posted October 26, 2010 Yeah, basically, I forgot to mention though, that the time of day when the page displays image #1 is completely random. I don't even know where to begin on this task... Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 26, 2010 Share Posted October 26, 2010 I'm thinking along these lines: One script runs on a cron job at midnight daily, generates the random time for the image to display for that day, and inserts that value in a database. The script that calls the image can then check the database, and if the time is between the random time and 2 minutes later, the alternate image is the one that gets served. Quote Link to comment Share on other sites More sharing options...
byrne86 Posted October 26, 2010 Author Share Posted October 26, 2010 OK, I understand most of that, but what is a cronjob? I know how to generate random numbers, but how would I generate a random time? Thanks for the help btw. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 26, 2010 Share Posted October 26, 2010 A cron job is a scheduled action on the server (I think it's called a 'scheduled task' in WinD'ohs). I've never had to generate a random time, so I haven't put much thought into it. Initially, I'm thinking you could generate a random between 0-23, and one from 00-59, and concatenate them into a time value, but somehow I'm not sure that's a good idea. Maybe someone else has a better way . . . Quote Link to comment Share on other sites More sharing options...
byrne86 Posted October 26, 2010 Author Share Posted October 26, 2010 It turns our I can easily use cron jobs with GoDaddy, so I can sort that out.In regards to the random time, I found this website: http://sqa.fyicenter.com/Online_Test_Tools/Random_Date_Time_Value_Generator.php but it doesnt explain how they get the random times very well. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.