Php 简单布尔函数
我目前有一个表格,它当前显示患者的信息并计算他们的等待时间 我在患者表中有一个布尔值Php 简单布尔函数,php,mysql,boolean,Php,Mysql,Boolean,我目前有一个表格,它当前显示患者的信息并计算他们的等待时间 我在患者表中有一个布尔值 Name Type Value Examined Tinyint(1) 0 我希望表格中的每一行都有一个简单的勾选框功能,允许用户选择是否对患者进行了检查;如果勾选该框,则该行将从表中消失,但不会从数据库中消失 我该怎么做 这是我的密码: <?php $conn = mysqli_connect("localhost","root","") or die ("No conne
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>
提前谢谢 最好使用JOIN从另一个表中添加一些字段 要选择检查的Tinyint(1)0为零的唯一行,最好使用where
<?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, Abs(TIMEDIFF(Expected_Time,'00:00:00')) as Expected,Abs(TIMEDIFF(Discharge_Time,'00:00:00')) as Discharge FROM Patient
JOIN priority_time USING (Illness, Priority)
WHERE Examined = 0";
$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()){
$expected = $row->Expected;
$discharge = $row->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文件发送请求,该文件将更新DBA,并向表patient添加布尔值,这表明他是否接受过医生的检查。在表格上为用户添加一个按钮,单击该按钮表示他们接收了患者,将此布尔值更改为true。通过这种方法无法实现?按钮在哪里?每行有8个th
,但只有7个td
。您还需要更改您的查询按钮将是一个勾选框;类似于这样的情况,如果勾选了,则患者已接受检查,并将布尔值更改为true