我有一个由mysql提供的php表,显示即将发生的事件。如果日期早于今天或者如果日期是今天,是否可以将css应用于表格单元格或行?我想为行红色ID日期的颜色可能比现在更早了吗?
显示日期的表格行的典型示例是<td><abbr class="timeago" title="<?php echo $row_rsEventChase['start_date']; ?>"></abbr></td>
任何帮助都非常感谢..
答案 0 :(得分:3)
这样做:
<td><abbr class="<?php echo ($row_rsEventChase['start_date'] <= (time() - 86400)) ? "old" : "new"; ?>" title="<?php echo $row_rsEventChase['start_date']; ?>"></abbr></td>
答案 1 :(得分:2)
$isOlderThanDay = (time() - $row_rsEventChase['start_date'] > 86400) ? true : false;
if ($isOlderThanDay) {
$css = "color: red;";
} else {
$css = "";
}
<td><abbr class="timeago" title="<?php echo $row_rsEventChase['start_date']; ?>" style="<?php echo $css; ?>"></abbr></td>
答案 2 :(得分:0)
是的,您可以检查单元格以便将样式应用于整行。例如:
<style>
tr.new td {
background: #FFC;
}
tr.old td {
background: #eee;
}
<style>
<tr class="<?php echo ($row_rsEventChase['start_date'] <= (time() - 86400)) ? "old" : "new"; ?>">
<td>....</td>
</tr>