Search code examples
phphtmlrel

how to add rel attribute to tr of table


I need to add rel attribute to the row of this table for some reason. I did this but it doesnt work. How should I do it?

<?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>";
    }     
?>

Solution

  • Use echo '<tr rel="'.$id.'">';

    echo outputs HTML code; <tr[rel=whatever]> is incorrect HTML.