Pregunta

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>";
    }     
?>
¿Fue útil?

Solución

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

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

Otros consejos

$id = $res['name'];
    echo "<tr rel = '".$id."'>";  
    echo "<td>".$res['roll']."</td>";
    echo "<td>".$res['name']."</td>";
    echo "<td>".$res['dept']."</td>";
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top