SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2012
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Close the survey on specified date

    Hi all.

    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 ?

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,219
    Mentioned
    153 Post(s)
    Tagged
    0 Thread(s)
    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()

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2012
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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 ?

  4. #4
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Where exactly are you storing the start/end dates at the moment?

  5. #5
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,219
    Mentioned
    153 Post(s)
    Tagged
    0 Thread(s)
    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()


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •