Anton Apua Escalante
Anton Apua Escalante

Reputation: 165

Php value change in database when time period is met

Hello currently working on my management system. So my problem is my student has a field of status. and has 2 values Enrolled and Not enrolled. Currently my enroll is working. My idea is once the system date would be April the students status would change from enroll to Not Enrolled , and when the students enrolled the status would change to enrolled no problem with the enroll part just the not enrolled part.

Would appreciate any ideas on how to perform this. Currently i am imagining an If else on my enroll page.

Upvotes: 0

Views: 206

Answers (1)

Nir Alfasi
Nir Alfasi

Reputation: 53535

I would add a new DATE column to the table and save only enrolled students information:

TABLE NAME: AAE_ENROLLED //(AAE stands for your initials ;) )
COLUMN 1: STUDENT_ID TYPE VARCHAR(50)
COLUMN 2: ENROLLMENT_DATE TYPE DATE

Say that you want all the students that enrolled after the beginning of April, all you have to do is:

select * from AAE_ENROLLED 
where ENROLLMENT_DATE > STR_TO_DATE('2012-04-01','%Y-%m-%d')

If you want to find students which where NOT enrolled you can use NOT EXIST

Upvotes: 1

Related Questions