Jump to content

help with View by Date from timestamp


shane85

Recommended Posts

hey guys...need some help with a math problem.

When entering information into my database, I have it so when it submits, it records a timestamp. One of the fields in my form is "Contact Next" and there is a drop down choice of

1 day

2 day

3 day

1 wk

2 wk

3 wk

1month

2month

3month

6month

 

These values are then stored as

 

01

02

03

07

14

21

1month

2month

3month

6month

 

in a column called contact_next in my db

 

How would I do it so each field kinda counts down to the day they are suppost to be contacted next? I have a button "View by Contact Next" and basically what I want this to do is view by time remaining from the timestamp, to the ammount of time they entered to contact next. Would it also be hard to take it 1 step further, and when the time is up, for instance if they put 3 days, on the 3rd day, send an email reminder??? This isnt spamming its not going to bug anyone other then myself as a reminder to contact the client! Just to put your worries to rest lol.

 

Anyway, please advise - and thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/197418-help-with-view-by-date-from-timestamp/
Share on other sites

You can find out the end time pretty easily ...

 

if you set the time stamp to record when they submitted the form, you just need to add time to the time stamp in whatever increments you have.

 

1 day for example is 86,400 seconds, so if they chose 1 day:

 

submitted: (when they submitted)

now: time();

contact: (submitted + 86,400)

 

if it is 3 days:

 

submitted:

now: time()

contact: (submitted + 259200)

 

and so on, so forth up until the time you want. You can then check how much time is left by using:

 

now: time()

contact: time to contact

time left: time to contact - now

 

Oh, as far as sending an email when their time is reached, you can set up a cron job that simply set's the current time...

 

it then checks the database for all records where the time stamp has already passed, but has a "received_email" of 0, which means they haven't been sent a message yet. The create a while loop  and have it send the message to those users, setting their "received email" to 1 ...

 

Would work.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.