0
我目前有一張表格,當前顯示有關患者的信息並計算他們的等待時間。簡單的布爾函數
我在患者表中有一個布爾值;
Name Type Value
Examined Tinyint(1) 0
我想在表中的每一行,它允許用戶選擇,如果病人已經研究了簡單的勾選框功能;如果勾選框,那麼該行將從表中消失,但不是數據庫。
我該怎麼做?
這裏是我的代碼:
<?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,NOW() as now,ABS(TIMEDIFF(NOW(), Arrival_time)) as Waiting_Time FROM Patient";
$result = mysqli_query($conn, $query) or die("Invalid query");
/**
* Convert number of seconds into hours, minutes and seconds
* and return an array containing those values
*
* @param integer $seconds Number of seconds to parse
* @return array
*/
function secondsToTime($seconds)
{
// extract hours
$hours = floor($seconds/(60 * 60));
// extract minutes
$divisor_for_minutes = $seconds % (60 * 60);
$minutes = floor($divisor_for_minutes/60);
// extract the remaining seconds
$divisor_for_seconds = $divisor_for_minutes % 60;
$seconds = ceil($divisor_for_seconds);
// return the final array
$obj = array(
"h" => (int) $hours,
"m" => (int) $minutes,
"s" => (int) $seconds,
);
return $obj;
}
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>
<th>Examined</th>
</tr>";
while ($row = $result->fetch_object()){
//Select the expected and discharge time for this patient.
$query2 = "SELECT Abs(TIMEDIFF(Expected_Time,'00:00:00')) as Expected,Abs(TIMEDIFF(Discharge_Time,'00:00:00')) as Discharge ".
"FROM priority_time ".
"WHERE Illness = '".$row->Illness."'".
" AND Priority = '".$row->Priority."'".
";";
$result2 = mysqli_query($conn, $query2) or die("Invalid statement: ".$query2);
$row2 = $result2->fetch_object();
$expected = $row2->Expected;
$discharge = $row2->Discharge;
if($expected > $discharge){
echo "There is a problem with the database consistency, expectedTime must be less than dischargeTime!";
}
//Set the patient color.
if($row->Waiting_Time < $expected && $row->Waiting_Time < $discharge){
echo "<tr>";
}
if($row->Waiting_Time >= $expected && $row->Waiting_Time < $discharge){
echo '<tr bgcolor="#FFFF00">';
}
if($row->Waiting_Time > $expected && $row->Waiting_Time > $discharge){
echo '<tr bgcolor="#FF0000">';
}
//Print patient info
echo
"<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>" . gmdate("H:i:s", $row->Waiting_Time)." </td>";
//Close row
echo "</tr>";
}
echo "</table>";
mysqli_close($conn);
?>
</html>
提前感謝!
你有什麼已經嘗試過?如果你沒有線索:最簡單的就是聯繫一個js庫(mootools,jquery,...),你需要一個當它應該消失時被調用的函數,然後改變爲css讓該行消失,通過ajax(POST/GET)發送一個請求到一個php文件,該文件將更新db – kero 2013-04-07 00:00:34
向表格病人添加一個布爾值,表示他是否被醫生檢查過。在表格上爲用戶添加一個按鈕,點擊這個按鈕表示他們接收到病人,並將此布爾值更改爲true。通過這種方法無法實現? – 2013-04-07 00:05:03
按鈕在哪裏?你有8×'th',但每行只有7×'td'。您需要更改您的查詢以及 – kero 2013-04-07 00:08:59