Jump to content

How to schedule random updates to my website


FalsAlarm

Recommended Posts

Hello everyone,

 

I have a database of information and links to images(photos) on my servers filesystem. I'd like to write a script that reads from the database and updates my webpage automatically. In my database I have a timestamp along with a title, description and a link to a relevant image(photo). I'd like to somehow read from the database and only show records that are past a given time. My database is mySQL and the timestamp in the database is stored as a mySQL datetime datatype.

 

1. How to I convert the mySQL datetime to a php date so that I can compare the current php time with the mySQL datetime and then make a decision to post records only those records that are before the current time plus a random time between 5 and 15 minutes.

 

Although I've been programming with php for awhile, I still can't quite wrap my mind around how the php code or sql query would look to perform this task.

 

My goal is to read from the database and post only those records that have a datetime that is anywhere from 5 to 15 minutes later than php's current time on the server.

 

I actually have a php form that I use to update the database with new records(title,description,image(photo) link). My goal is to have the website auto update itself based on the records that I have scheduled to be posted based on 5 to 15 minutes from my php current time.

 

I usually write object oriented php, any help on some idea's about how this should/could be done would be appreciated.

 

please and thanks,

 

FalsAlarm,

Link to comment
Share on other sites

It just occured to me that when I insert the record(s) into the database, at that time, I should be creating the datetime to be stored and I should be inputting a random time. So I guess i'm already partly the way there. Any idea's on how I could check the last records datetime in the database and generate a random time between the current time and 5 to 15 minutes later so that I can put that code into the form pages code would help as well.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.