Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8703371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:51:18+00:00 2026-06-13T02:51:18+00:00

I have a Session Table below: SessionId(Auto) SessionName SessionDate SessionTime Duration Active 1 AASEA

  • 0

I have a “Session” Table below:

SessionId(Auto) SessionName  SessionDate SessionTime Duration  Active
1               AASEA        21-09-2012  09:00:00    01:00:00  1
2               SDERF        11-09-2012  10:00:00    01:00:00  1
3               DERSD        30-11-2012  12:00:00    01:30:00  1

Now what I want to do is use CRON to be able to set the Sessions above to “Active” – 0 if the Session was held eaxactly week before 21/10/2012 or earlier of the current year. So in Session Table above, it should make the first 2 rows inactive by changing “Active” to 0. The third row won’t obviously change as its start date is later on. So that session won’t become automatically inactive till October 21st 2013.

So I want to know as that I havn’t used CRON before and this is a delicate task as it needs to be tested to ensure it works, does somebody know how to write the php/CRON script so that it does the following:

  • Sets the “Active” value to 0 for all sessions which start date is exactly a week or before the date of 21st October of the current year?
  • It must be able to know what the current year is automatically
  • This procedure happens yearly every 21st October of each year

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:51:19+00:00Added an answer on June 13, 2026 at 2:51 am

    Write this script in a php file and save it somewhere in the application directly.

    <?php
    $con = mysql_connect("localhost","root","password");
    $db = mysql_select_db("your_database");
    
    
    $createDate = mktime(0,0,0,10,21,date("Y"));
    $selectedDate =  date('d-m-Y', ($createDate));
    $sql = mysql_query("UPDATE Session SET Active = 0 WHERE DATE_FORMAT(SessionDate,'%Y-%m-%d' ) <= '".$selectedDate."'");
    
    ?>
    

    Now you need to login to your hosting site – cPanel and access CRON jobs. There you need to set up a new CRON job.This is a tutorial of how to set up a cron job – http://www.youtube.com/watch?v=0OBvGbyj15Q

    Just replace the url used in the video with the script written above and it should work fine for you. Make sure you replace the credentials and the database.

    You can set the cron job on 21st October every year or can run it everyday. Our script anyways validates the date, so no problem if you run the cron job every day also. This is not an expensive query and so the resources used are bare minimum.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Answer database table below: Answer Table AnswerId SessionId QuestionId Answer 13
I have an Answer database table below: Answer Table AnswerId SessionId QuestionId Answer 13
I have an Answer database table below: Answer Table AnswerId SessionId QuestionId Answer 10
I have this query below: SELECT q.SessionId, s.SessionName, q.QuestionId, q.QuestionContent, GROUP_CONCAT(DISTINCT Answer ORDER BY
I have a table (session) in a database which has almost 72,000 rows. I
I have a table like below: uid nid points date reason 36 116 2
I don't know if it's possible but below I have a simple html table:
I have a little situation here. If in my database in my Session Table
I have three tables - Context, Session and User. And below are their simplified
I have a table (session_comments) with the following fields structure: student_id (foreign key to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.