Question

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

Solution

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

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

OTHER TIPS

$id = $res['name'];
    echo "<tr rel = '".$id."'>";  
    echo "<td>".$res['roll']."</td>";
    echo "<td>".$res['name']."</td>";
    echo "<td>".$res['dept']."</td>";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top