我有一个脚本,它从php结果返回5列。我试图将其中一列到期日与当前日期相匹配。如果返回的日期较旧,我想突出显示该行。它似乎不是出于某种原因。我测试了我的if语句并且它有效。
<?php
// First of all initialise the user and check for permissions
require_once "/var/www/users/user.php";
$user = new CHUser(7);
// Initialise the template
require_once "/var/www/template/template.php";
$template = new CHTemplate();
// And create a cid object
require_once "/var/www/WIPProgress/DisplayWIPOnLocation.php";
$WIPProgress= new CHWIPProgress();
$content = "<h1>Check WIP Status on Location </h1>";
$content =
"<form action='index.php' method='get' name ='location'>
<select id='location' name ='location' >
<option>Skin Room</option>
<option>Clicking</option>
<option>Kettering</option>
<option>Closing</option>
<option>Rushden</option>
<option>Assembly</option>
<option>Lasting</option>
<option>Making</option>
<option>Finishing</option>
<option>Shoe Room</option>
</select>
<input type='submit' />
</form>";
if(isset($_GET['location'])) {
$wip = $WIPProgress->ListWIPOnLocation($_GET['location']);
$location = $_GET['location'];
$todays_date = date("Y-m-d H:i:s");
// Now show the details
$content .=
"<h2>Details for $location </h2>
<table>
<tr>
<th>PPDescription</th>
<th>Works Order</th>
<th>Bundle Number</th>
<th>Bundle Reference</th>
<th>Due Date</th>
</tr>";
foreach($wip as $x) {
if(strtotime($x['DueDate']) > strtotime($todays_date)){
$content .=
"<tr bgcolor='#FF0000'>
<td>" . $x['Description'] . "</td>
<td>" . $x['WorksOrder'] . "</td>
<td>" . $x['Number'] . "</td>
<td>" . $x['Reference'] . "</td>
<td>" . $x['DueDate'] . "</td>
</tr>";
}
}
}
else {
$content .= "<h3>Please choose a location to view WIP</h3>";
}
$template->SetTag("content", $content);
echo $template->Display();
?>
php中是否有可用的类突出显示返回的行?
答案 0 :(得分:0)
不要使用bgcolor
定义tr
,而是定义每个td
。
或者更好的方法将CSS类与tr
相关联,并通过CSS定位此td
的所有tr
。
$content .= "<tr class='highlight'>...";
<style>
.highlight td
{
background-color:#FF0000;
}
</style>