how to add rel attribute to tr of table

北慕城南 提交于 2019-12-11 20:09:48

问题


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

回答1:


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

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




回答2:


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


来源:https://stackoverflow.com/questions/19767093/how-to-add-rel-attribute-to-tr-of-table

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!