//这是我的更新代码,它现在将当前时间与 在mysql中节省了时间,但我的问题是它只与它相比 第一次增加时间我需要的是当前时间将它与之比较 最近的时间保存在mysql中。
<?php
//Include the database configuration
include 'config.php';
//Get the data of the selected teacher
$teacher = $dbconnect->prepare("SELECT * FROM teacher_info
WHERE IMEI = ? AND NFC = ?");
$teacher->bindValue(1,$_GET['IMEI']);
$teacher->bindValue(2,$_GET['NFC']);
$teacher->execute();
//Get the data
$teacher_info = $teacher->fetch();
//If there is such a teacher let the teacher enter
if(!empty($teacher_info))
{
$time_out = $dbconnect->prepare("INSERT INTO time_out (teacher_id,name,NFC,IMEI,time_out) VALUES (?,?,?,?,NOW())");
$time_out->bindValue(1,$teacher_info['teacher_id']);
$time_out->bindValue(2,$teacher_info['name']);
$time_out->bindValue(3,$teacher_info['NFC']);
$time_out->bindValue(4,$teacher_info['IMEI']);
$time_out->execute();
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Welcome!</title>
</head>
<body>
<h1>
<?php
//If there is such a teacher,welcome him/her
if(!empty($teacher_info))
{
echo 'Welcome '.$teacher_info['name'].'! Your NFC is '.$teacher_info['NFC'];
}
else
{
echo 'You are not registered.';
}
?>
</h1>
</body>
</html>
//Hope you can help me out
答案 0 :(得分:1)
假设表time_in
time_in
列
if($stmt = $dbconnect->prepare("SELECT time_in from time_in")){
$stmt->bind_param("s", $time_in);
$stmt->execute();
$cur_time = time();
if($time_in === $cur_time){
echo "Teacher is on time";
}
}
这主要是关于事情应该如何发展的想法。总是有改进的余地。确切地说,您应该在teacher_id
表中提供time_in
,以便仅选择相应教师的时间。
修改强>
if($stmt = $dbconnect->prepare("SELECT time_in from time_in")){
$stmt->bind_param("s", $time_in);
$stmt->execute();
if($stmtt = $dbconnect->prepare("SELECT time from profschedule")){
$stmtt->bind_param("s", $time);
$stmt->execute();
if($time_in === $time)
echo "Teacher is on time";
}}}
尽管如此,这篇文章写得不好,但其重点在于在评论中检查您的观点后,为您提供有关如何处理的IDEA。