Mysql
 sql >> Base de données >  >> RDS >> Mysql

Le temps SQL dépasse

$query = "SELECT PatientID, Forename, Surname, Gender, Illness, Priority, Arrival_time,
          TIME_FORMAT(ABS(TIMEDIFF(CURTIME(), Arrival_time)),'%H hours') as Waiting_Time 
          FROM Patient
          ORDER BY TIMEDIFF(CURTIME(), Arrival_time) DESC";

Ensuite, vos résultats sont classés avec la plus longue attente en premier.

<?php

while ($row = $result->fetch_object()): ?>

  <tr>
    <td><?=$row->PatientID?></td>
    <td><?=$row->Forename?></td>
    <td><?=$row->Surname?></td>
    <td><?=$row->Gender?></td>
    <td><?=$row->Illness?></td>
    <td><?=$row->Priority?></td>
    <td><?=$row->Waiting_Time?>
        <? if ($row->Waiting_Time >= 3): ?>
            <strong>Patient must be seen!</strong>
        <? endif; ?>
    </td>
  </tr>

<? endwhile; ?>