【发布时间】:2020-09-28 16:19:12
【问题描述】:
我想为表格的一列设置一个计时器,该列包含时间,我想为此列设置一个计时器。该列的每个单元格都有一个特定的时间,如果该时间是该小时的 20 分钟之前的 1 小时,它应该显示一个弹出消息,表明时间即将结束。
下面是我的桌子:
列名:时差
<body>
<div class="card-body">
<table class="table">
<thead>
<tr>
<th>IdCard</th>
<th>Name</th>
<th>Company</th>
<th>Floors</th>
<th>Arrival</th>
<th>Departure</th>
<th>Time Difference</th>
</tr>
</thead>
<?php
include('includes/dbconnection.php');
$sql="SELECT *,
TIME_FORMAT(arrival, '%h:%i %p') AS arrival,
TIME_FORMAT(departure, '%h:%i %p') AS departure,
TIME_FORMAT(timediff(departure, arrival), '%H:%i') AS difftime
FROM master where Status = 'Pending'";
$query = $dbh -> prepare($sql);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($query->rowCount() > 0) {
foreach($results as $row) {
?>
<tr>
<!-- <td><?php echo htmlentities($cnt);?></td>-->
<td><?php echo htmlentities($row->idcard);?></td>
<td><?php echo htmlentities($row->name);?></td>
<td><?php echo htmlentities($row->company);?></td>
<td><?php echo htmlentities($row->floors);?></td>
<td><?php echo htmlentities($row->arrival);?></td>
<td><?php echo htmlentities($row->departure);?></td>
<td><span style="color: red;"><?php echo htmlentities($row->difftime);?></span></td>
</tr>
<?php
$cnt=$cnt+1;
}
}
?>
</table>
</div>
</body>
【问题讨论】:
-
为什么有 2 个
<tr>标签相互跟随 -
良好的代码缩进将帮助我们阅读代码,更重要的是它将帮助您调试您的代码Take a quick look at a coding standard为您自己的利益。您可能会被要求在几周/几个月内修改此代码,最后您会感谢我的。
-
@RiggsFolly 已编辑