Jump to content

update mysql field on a certain time

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
arxh

arxh

    Newbie

  • Members
  • PipPip
  • 24 posts
i want to execute a script that will update a mysql field on a certain timestamp
..... for eg : after 3600 seconds from now .. mysql field named 'status' should be changed from 0 to 1

how can i do this...

plss help

#2
Guest_johnny.dacu_*

Guest_johnny.dacu_*
  • Guests
This can be accomplish with cron jobs. I'm not sure if you can setup one on runtime...

#3
arxh

arxh

    Newbie

  • Members
  • PipPip
  • 24 posts
is there another way???

if no... can you tell me in detail what i have to do..
actually. users will be submitting their birth date ... and on their birth day at a specific time (say 8 hours) mysql updates ......
so there would be lots of submissions/... and i want everything automated

#4
Roger

Roger

    If nothing goes right, go left.

  • Administrators
  • 718 posts
Can you describe your requirements a little more?

- A user submits their birthday (on your website?)
- Your PHP page saves it to DB
- On the actual birthday, your DB will need to update a "status" field to "1"
- Does the field need to revert back to "0" after the birthday?
- Do you have access to cron?
- How often is your site accessed? Can you trigger a PHP file within another PHP file that would change the status?

Technically, if you can set a script to update the DB, you can trigger that page many different ways:
- cron
- within another page
- you can even use a free website monitoring tool that'll download the PHP page every hour.. behaving like a cron job
Check out our update Guidelines/FAQ. When posting code, remember to use code tags - Posted Image.

#5
arxh

arxh

    Newbie

  • Members
  • PipPip
  • 24 posts
no.. the status would not need to revert to 0...

running the script every hour would not work ... coz i want the field to update on the exact timestamp..

for eg: visit 99designs.com >browse projects> click on any project

you'll notice that for the time remaining they have a countdouwn timer....... which runs till the last second.... and when the end timestamp occurs ... the project disappears from the list...

#6
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
You don't have to do this live. just enable due posts at each page show, and the problem is solved. if noone looks at the page, there is no reason to enable it, but then enable as soon as someone looks at it.

Example: Run this query at first part of each page view, before you start listing posts from here
UPDATE table_name SET active = 1 WHERE active = 0 AND time_field < NOW()

__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#7
arxh

arxh

    Newbie

  • Members
  • PipPip
  • 24 posts
kkk.... got it
thankss

#8
Roger

Roger

    If nothing goes right, go left.

  • Administrators
  • 718 posts
Good call, Orjan.
Check out our update Guidelines/FAQ. When posting code, remember to use code tags - Posted Image.