如果结果高于某个值,PHP MySQL将变为红色

时间:2014-10-10 15:50:54

标签: php mysql conditional

需要一些帮助。

我有这个问题......

$query2 = "
SELECT HD_TICKET.ID as ID, 
HD_TICKET.TITLE as Title, 
HD_STATUS.NAME AS Status, 
HD_PRIORITY.NAME AS Priority, 
HD_TICKET.CREATED as Created, 
HD_TICKET.MODIFIED as Modified, 
HD_TICKET.CUSTOM_FIELD_VALUE10 as SLA,
S.FULL_NAME as Submitter, 
O.FULL_NAME as Owner, 
HD_TICKET.RESOLUTION as Resolution,
(SELECT COMMENT FROM HD_TICKET_CHANGE WHERE HD_TICKET_ID=HD_TICKET.ID ORDER BY TIMESTAMP DESC LIMIT 1) as Comment,
HD_TICKET.CUSTOM_FIELD_VALUE0 as Type 
FROM HD_TICKET 
JOIN HD_STATUS ON (HD_STATUS.ID = HD_TICKET.HD_STATUS_ID) 
JOIN HD_PRIORITY ON (HD_PRIORITY.ID = HD_TICKET.HD_PRIORITY_ID) 
LEFT JOIN USER S ON (S.ID = HD_TICKET.SUBMITTER_ID) 
LEFT JOIN USER O ON (O.ID = HD_TICKET.OWNER_ID)
WHERE (HD_TICKET.HD_QUEUE_ID IN( 1,3))
AND (DATE_FORMAT(HD_TICKET.TIME_CLOSED, '%M') = 'September')
ORDER BY HD_TICKET.TIME_CLOSED DESC
";

这是在我的页面中显示此内容的输出。

echo "<td>$Title</td> \n";
echo "<td>$Submitter</td> \n";
echo "<td>$Owner</td> \n";
echo "<td>$Status</td> \n";
echo "<td>$Created</td> \n";
echo "<td>$Modified</td> \n";
echo "<td>$SLA</td> \n";
echo "</tr> \n";

如果修改时间大于72小时,有没有办法有条件地将行背景变为红色?

Basicallty想要标记在72小时内未修改过的任何行。

感谢。

1 个答案:

答案 0 :(得分:2)

if(strtotime($Modified) < strtotime("-72h"))
 echo "<td class='red'>$Modified</td> \n";
else
 echo "<td>$Modified</td> \n";