do it in the sql query since you already have the arrival time in the DB
$query = "SELECT PatientID, Forename, Surname, Gender, Illness, Priority, Arrival_Time, TIMEDIFF(Arrival_time,NOW()) as Waiting_Time FROM Patient";
Also in your example above your only ever comparing now time to now time never actually comparing against Arrival_Time from your DB
Example modified version of your code
PatientID |
Forename |
Surname |
Gender |
Illness |
Priority |
Waiting Time |
";
while ($row = $result->fetch_object()){
echo "
" . $row[0] . " |
" . $row[1] . " |
" . $row[2] . " |
" . $row[3] . " |
" . $row[4] . " |
" . $row[5] . " |
" . $row[7] . " |
";
}
echo "";
mysqli_close($conn);
?>