【问题标题】:how to add rel attribute to tr of table如何将rel属性添加到表的tr
【发布时间】:2013-11-04 11:47:07
【问题描述】:

出于某种原因,我需要在此表的行中添加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>";
    }     
?>

【问题讨论】:

  • how to prevent same table row from cloning 的可能重复项(可能不重复,但与上一个问题明显相关。)
  • rel 是合法属性吗?你也忘了在你的脚本中关闭你的tr 标签
  • 我假设您知道rel 不允许在tr 上使用?

标签: php html rel


【解决方案1】:

使用echo '&lt;tr rel="'.$id.'"&gt;';

echo 输出 HTML 代码; &lt;tr[rel=whatever]&gt; 是不正确的 HTML。

【讨论】:

    【解决方案2】:
    $id = $res['name'];
        echo "<tr rel = '".$id."'>";  
        echo "<td>".$res['roll']."</td>";
        echo "<td>".$res['name']."</td>";
        echo "<td>".$res['dept']."</td>";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-21
      相关资源
      最近更新 更多