conditional formatting html table in php with time stamp comparison

后端 未结 3 1574
梦如初夏
梦如初夏 2021-01-28 03:03
echo \'\';
echo \'\'; 
echo \'\';
echo \'
3条回答
  •  心在旅途
    2021-01-28 03:40

    Do an if to see if time is over 60 minutes and if so assign it a class with a different background color. Since you didn't clarify I'm going to assume you are using unix timestamp time().

    $currTime = time();
    
    if($result) {
    while($row = mysqli_fetch_assoc($result)) { 
        $calc = $currTime - $row['TimeStamp'];
        if($calc > 3600){
        $rowClass = "oldOrder";
        } else {
        $rowClass = "normalOrder";
        }
    echo '
'; }

Then add CSS to define the two classes

.oldOrder{
background-color: #ccc;
}
.normalOrder{
background-color: #fff;
}

提交回复
热议问题
OrderDestinationLocation
'; echo $row['OrderNumber'] . ''; echo ''; echo $row['Destination'] . ''; echo ''; echo $row['Location'] . ''; echo ''; echo $row['Status'] . ''; echo ''; echo $row['TimeStamp'] . ''; echo '