Php 突出显示结果中的行
我有一个脚本,它从php结果返回5列。我正在尝试将其中一列的到期日期与当前日期进行匹配。如果返回的日期较旧,我想突出显示该行。出于某种原因,它似乎不起作用。我已经测试了我的if语句,它工作正常Php 突出显示结果中的行,php,sql,Php,Sql,我有一个脚本,它从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); //
<?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();
?>
而不是用tr
定义bgcolor
,而是用其中的每个td
定义
或者更好地将CSS类与tr
关联,并通过CSS将此tr
的所有td
作为目标
$content .= "<tr class='highlight'>...";
<style>
.highlight td
{
background-color:#FF0000;
}
</style>
$content.=“…”;
.突出显示运输署
{
背景色:#FF0000;
}
您缺少正常的流程,所以您只打印高亮显示的单元格?不,我只是想强制打印,您的if语句中没有其他内容。。。如果你想显示每一行,我觉得很奇怪。你用的是什么浏览器?您能显示生成的HTML代码吗?谢谢您,这是有效的,但我接受了advice并添加了else语句,否则它将无法工作。