<div class="table-responsive">
<table id="Well_CAT" class="table table-striped table-bordered">
<thead> <th>Client_Contract_Number</th>
<th>Currently_Using</th>
<th>MBPS_EAM_Number_RIGT</th>
<th>Model_and_Type</th>
<th>LFour_Yearly</th>
<th>Six_Monthly</th>
<th>One_Yearly</th>
<th>One_and_Half_Yearly</th>
<th>Two_Yearly</th>
<th>Two_and_Half_Yearly</th>
<th>Three_Yearly</th>
<th>Three_and_Half_Yearly</th>
<th>Four_Yearly</th>
<th>Remarks</th>
</thead>
<?php
while($rows=mysql_fetch_array($result)){
?><tr>
<td class="exdate"><? echo $rows['Client_Contract_Number']; ?></td>
<td class="exdate"><? echo $rows['Currently_Using']; ?></td>
<td><? echo $rows['MBPS_EAM_Number_RIGT']; ?></td>
<td><? echo $rows['Model_and_Type']; ?></td>
<td><? echo $rows['LFour_Yearly']; ?></td>
<td class="exdate"><? echo $rows['Six_Monthly']; ?></td>
<td class="exdate"><? echo $rows['One_Yearly']; ?></td>
<td class="exdate"><? echo $rows['One_and_Half_Yearly']; ?></td>
<td class="exdate"><? echo $rows['Two_Yearly']; ?></td>
<td class="exdate"><? echo $rows['Two_and_Half_Yearly']; ?></td>
<td class="exdate"><? echo $rows['Three_Yearly']; ?></td>
<td class="exdate"><? echo $rows['Three_and_Half_Yearly']; ?></td>
<td class="exdate"><? echo $rows['Four_Yearly']; ?></td>
<td class="exdate"><? echo $rows['Remarks']; ?></td>
</tr>
<?php
}
?>
</table>
下面是我的表格,它是跟踪证书的有效性,从 Lfour 年到四年的列是日期字段,我想根据有效性对这些字段进行条件颜色格式...比如如果有效 - 绿色,过期 - 红色。
从 PHP >= 5.2.0 开始,您可以这样使用 DateTime 类:
if (new DateTime() > new DateTime("2010-05-15 16:00:00")) {
# current time is greater than 2010-05-15 16:00:00
# in other words, 2010-05-15 16:00:00 has passed
}
传递给 DateTime 构造函数的字符串将根据这些规则进行解析。
这是您的代码的示例:
<td class="exdate" style="color:<?php echo (new DateTime() > new DateTime($rows['Six_Monthly'])) ? 'red' : 'green'; ?>;" ><? echo $rows['Six_Monthly']; ?></td>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)