我可以看到生成的 html 表,但是根据我定义的名为“匹配”的 CSS 类,行没有突出显示?我的目标是突出显示满足 SQL 查询中定义的匹配条件的每一行。我认为该错误与match
SQL 查询中定义的变量有关,而不是 PHP?
<?php
require_once 'config.php';
$dbh = new PDO($dsn, $dbuser, $dbpass);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$result = $dbh->query("
SELECT a_aif.aif_id,
a_aif.fee_source_id,
a_aif.company_name_per_sedar,
a_aif.document_filing_date,
IF (a_aif_remaining.aif_id IS NULL, 0, 1) `match`
FROM a_aif
LEFT JOIN a_aif_remaining
ON a_aif_remaining.aif_id = a_aif.aif_id
ORDER BY aif_id DESC");
$result->setFetchMode(PDO::FETCH_ASSOC);
if ( !empty($result) ) : endif;
?>
<table>
<tr>
<th><b>Document ID</b></th>
<th><b>Pubco Name</b></th>
<th><b>Filing Date</b></th>
<th><b>PDF</b></th>
</tr>
<?php foreach($result as $index => $row) : ?>
<tr class="<?=$v["match"] ? "match" : ""?>">
<td><?php echo $row[fee_source_id]; ?></td>
<td><?php echo $row[company_name_per_sedar]; ?></td>
<td><?php echo $row[document_filing_date]; ?></td>
<td></td>
</tr>
<?php endforeach;
$dbh = NULL;
?>
</table>