0
我寫了一段代碼來計算病人的等待時間如下;簡單的代碼超過時間
$query = "SELECT PatientID, Forename, Surname, Gender, Illness, Priority, Arrival_time, TIME_FORMAT(ABS(TIMEDIFF(CURTIME(), Arrival_time)),'%H hours') as Waiting_Time FROM Patient";
哪個顯示以下數據:如示例所示
PatientID Forename Surname Gender Illness Priority Waiting Time
625 Max Courts M non-urgent moderate 4 hours
;等待時間爲4小時; 我需要一段代碼來檢測並提醒time
是MORE THAN
4小時;以迴應警報。
我試過的示例代碼;
if $waitingtime == >4 hours
then echo "patient must be seen!"
編輯全碼
<?php
$conn = mysqli_connect("localhost","root","") or die ("No connection");
mysqli_select_db($conn, "a&e") or die('Could not select database.');
$query = "SELECT PatientID, Forename, Surname, Gender, Illness, Priority, Arrival_time, TIME_FORMAT(ABS(TIMEDIFF(CURTIME(), Arrival_time)),'%H hours') as Waiting_Time FROM Patient";
$result = mysqli_query($conn, $query) or die("Invalid query");
echo "<table border='1'>
<tr>
<th>PatientID</th>
<th>Forename</th>
<th>Surname</th>
<th>Gender</th>
<th>Illness</th>
<th>Priority</th>
<th>Waiting Time</th>
</tr>";
while ($row = $result->fetch_object()){
echo "<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 . "</td>
</tr>";
}
echo "</table>";
mysqli_close($conn);
?>
上一個相同的問題仍然是打開的。如果您沒有得到很好的答案,請考慮更新它,而不是創建相同的答案。 – Tchoupi 2013-03-26 17:34:19
因爲我需要幫助,而且我多次編輯了這個問題 – 2013-03-26 18:02:43