如何将 rel 属性添加到表的 tr


how to add rel attribute to tr of table

出于某种原因,我需要将rel属性添加到此表的行中。我这样做了,但它不起作用。我应该怎么做?

<?php
    $query = $con->prepare("query");
    $query->execute();
    while($result = $query->fetch(PDO::FETCH_ASSOC)) {
        $id = $res['name'];
        echo "<tr[rel = '".$id."']>";  
        echo "<td>".$res['roll']."</td>";
        echo "<td>".$res['name']."</td>";
        echo "<td>".$res['dept']."</td>";
    }     
?>

使用echo '<tr rel="'.$id.'">';

echo输出 HTML 代码; <tr[rel=whatever]>是不正确的 HTML。

$id = $res['name'];
    echo "<tr rel = '".$id."'>";  
    echo "<td>".$res['roll']."</td>";
    echo "<td>".$res['name']."</td>";
    echo "<td>".$res['dept']."</td>";