We have to do online classes again here in Nanjing, because of the virus. I have to keep a record of attendance.
The code below increments the attendance when a student logs in. Works fine.
The has_been_inc column is also incremented if it is not already 1. This prevents students from logging in multiple times and upping the attendance. This all works fine.
Before the next class I reset the has_been_inc column to zero.
What I want to do is also NOT increment the attendance if a student comes late. Not quite sure how to realise that.
// MY STUFF HOPE THIS WORKS!!
try{
// attendance will not increase with multiple logins. Before next week, reset 'has_been_inc' to zero from phpmyadmin
$mystmt = $pdo->prepare('UPDATE allstudents20EAP SET attendance = attendance + 1, has_been_inc = has_been_inc + 1, logon_time = LOCALTIME() WHERE email = :email AND has_been_inc != 1');
$mystmt->execute(['email' => $email]);
}
catch (PDOException $e){
$_SESSION['exception'] = $e->getMessage();
//if(!$e == ''){
//echo 'PDOException' . $e;
//exit();}
}
// END MY STUFF
I think I need another AND LOCALTIME() !> How to format the time here??
I tried this just in phpMyAdmin, with brackets, with apostrophes, but I get an error:
UPDATE allstudents20EAP SET attendance = attendance + 1, has_been_inc = has_been_inc + 1, logon_time = LOCALTIME() WHERE email = '[email protected]' AND LOCALTIME() !> (2021-08-21 11:00:00)AND has_been_inc != 1
How should I format the time in this LOCALTIME() !> command??
Maybe the time must be in seconds??