Je souhaite changer la couleur de toute la ligne en fonction de la durée de la date. Par exemple, si la durée de la date est comprise entre 3 et 6, la couleur est orange, plus de 6 doit être affiché en rouge ; Puis-je savoir comment je peux faire cela ?
foreach ($ary_list as $k => $v) { $color= xxx; echo "<tr style=\"color:$color\">"; echo "<tr bgcolor=\"#F5F5F5\">\n"; echo "<td nowrap ".$rowspan.">\n"; echo "<font face=\"arial\" size=\"1\" color=\"#3C5F84\">\n"; echo "  " .$v["seal_area"]. "     "; echo "</font>\n"; echo "</td>\n"; echo "<td nowrap ".$rowspan.">\n"; echo "<font face=\"arial\" size=\"1\" color=\"#3C5F84\">\n"; echo "  " .$v["seal_barcode"]. "     "; echo "</font>\n"; echo "</td>\n"; echo "<td nowrap ".$rowspan.">\n"; echo "<font face=\"arial\" size=\"1\" color=\"#3C5F84\">\n"; echo "  " .$v["dt_issue"]. "     "; echo "</font>\n"; echo "</td>"; echo "<td nowrap ".$rowspan.">\n"; echo "<font face=\"arial\" size=\"1\" color=\"#3C5F84\">\n"; echo "  " .$v["issue_admin"]. "     "; echo "</font>\n"; echo "</td>"; echo "<td nowrap ".$rowspan.">\n"; echo "<font face=\"arial\" size=\"1\" color=\"#3C5F84\">\n"; echo "  " .$v["receive_by"]."     "; echo "</font>\n"; echo "</td>"; echo "<td nowrap ".$rowspan.">\n"; echo "<font face=\"arial\" size=\"1\" color=\"#3C5F84\">\n"; echo "  " .$v["receive_id"]."     "; echo "</font>\n"; echo "</td>"; echo "<td nowrap ".$rowspan.">\n"; echo "<font face=\"arial\" size=\"1\" color=\"#3C5F84\">\n"; echo "  " .$v["dt_return"]."     "; echo "</font>\n"; echo "</td>"; echo "<td nowrap ".$rowspan.">\n"; echo "<font face=\"arial\" size=\"1\" color=\"#3C5F84\">\n"; echo "  " .$v["return_admin"]."     "; echo "</font>\n"; echo "</td>"; echo "<td nowrap ".$rowspan.">\n"; echo "<font face=\"arial\" size=\"1\" color=\"#3C5F84\">\n"; echo "  " .$v["return_by"]. "     "; echo "</font>\n"; echo "</td>"; echo "<td nowrap ".$rowspan.">\n"; echo "<font face=\"arial\" size=\"1\" color=\"#3C5F84\">\n"; echo "  " .$v["return_id"]."     "; echo "</font>\n"; echo "</td>"; /*echo "<td nowrap ".$rowspan.">\n"; echo "<font face=\"arial\" size=\"1\" color=\"#3C5F84\">\n"; $now = time(); // or your date as well $your_date = strtotime($v["dt_issue"]); $datediff = $now - $your_date; //echo round($datediff / (60 * 60 * 24)); //echo $datediff->format('%R%a days'); echo "  " .round($datediff / (60 * 60 * 24))."     "; echo "</font>\n"; echo "</td>";*/ echo "<td nowrap ".$rowspan.">\n"; $now = time(); $your_date = strtotime($v["dt_issue"]); $datediff = $now - $your_date; $daysDiff = round($datediff / (60 * 60 * 24)); $color = $daysDiff < 3 ? '#3C5F84' : ($daysDiff <= 6 ? 'orange' : 'red'); echo "<font face=\"arial\" size=\"1\" color=\"$color\">\n"; echo "  " .$daysDiff."     "; echo "</font>\n"; echo "</td>"; echo "</tr>"; }
Le code ci-dessus est la façon dont je calcule l'onglet temps de cycle en php. Pour dt_issue, ceci est utilisé avec now() lors de l'insertion de la requête. J'insérerai une capture d'écran ci-dessous.
Vous pouvez essayer de changer la couleur de la police en fonction des joursdiff