【发布时间】:2017-06-18 21:46:08
【问题描述】:
$html -> holds the html table code
$query ->holds the data fetched from table(Oracle)
我将数据从 $query 插入到 $html,并根据条件进行颜色编码
代码:
while (my @rec = $query->fetchrow_array() ) {
my $file_status = $rec[9];
my $data_status = $rec[11];
my $data_status2 = $rec[13];
if ($file_status eq "Files Received"
|| $data_status eq "Data Not Found"
|| $data_status2 eq "Partial Data") {
# This changes the font color for all columns in a single row.
# Is there a way to color code only the specific column?
$html=$html."\n<font size=3 color=#F12A3D>";
}
else {
$html = $html."\n<font size=3><tr>";
}
foreach my $x (@rec) {
if (! defined $x) {
$x = "";
}
$html = $html."<td>$x</td>"
}
$html = $html."</tr>"
}
如果列值与条件匹配,请告诉我是否可以使用 perl 中的 html 对特定列进行颜色编码(例如,如果列 8="a" 用于记录,那么我必须打印只有第 2 列的行红色)。如果需要,我可以分享这个脚本的完整 perl 代码。
谢谢, 斯科特
【问题讨论】:
-
请对您的代码进行布局以使其可读。在寻求免费帮助以使其正常工作时,这是您至少可以做的。
-
/-- ... --/不会在 Perl 或任何我知道的语言中创建评论。 -
如何更改
<td>,而不是整个<tr>? -
我已重新格式化您的代码以使其更易于理解。不客气,但下次请自己做。