On my website, i want to start a survey on 9th October 12:00 am and close it on 12th Oct 12:00 am. Currently i am bit confused how to achieve this ? i mean how will the script (php) on my website knows that now is the time to mark this survey closed ?
Usually you store the date/time of the start and close in a table or some file, when you read the file to see what survey is available you would put the following as a condition
WHERE start_date <= NOW() AND end_date > NOW()
Sir, basically i want to give a list of surveys that viewers can fill. But i also want to show the surveys that are closed. So do i need a cronjob that will scan the database at regular intervals to see which survey should be closed ? or is there any other way to do it ?
Where exactly are you storing the start/end dates at the moment?
No, you can just use the end_date column. You "could" use a cronjob, but you don't need to.
SELECT columns, IF (end_date <= NOW(), 'Closed', 'Open') AS Status FROM table WHERE start_date <= NOW()
This topic is now closed. New replies are no longer allowed.