SQL Time exceeds

后端 未结 1 465
深忆病人
深忆病人 2021-01-26 12:15

I currently have a system that outputs a waiting time, given their arrival time and current time; (current time - arrival time). How would I programme the code so that;

相关标签:
1条回答
  • 2021-01-26 13:06
    $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";
    

    Then your results are ordered with the longest wait first.

    <?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; ?>
    
    0 讨论(0)
提交回复
热议问题