how to compare the two fields in php with different table in mysql?

Assuming that you have a time_in column in the table 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";
}
}

This is mainly an idea about how things should be going. There’s always room for improvement. To be precise, you should give a teacher_id in the time_in table so that the respective teacher’s time is selected only.

EDIT:

 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";
}}}

Although, this is poorly written but the whole point of it is to give you the IDEA about how to approach after inspecting your perspective in the comments.

Leave a Comment