使td表的内容可链接

问题描述:

Please can someone review this code and tell me how to get the content of <td> table clickable?

<?php
    include 'database.php';
    $pdo = Database::connect();
    $sql = 'SELECT * FROM products ORDER BY product_id DESC';
    foreach ($pdo->query($sql) as $row) {
        echo '<tr>';
        echo '<td>'. $row['cat_id']        . '</td>';
        echo '<td>'. $row['brand_id']      . '</td>';
        echo '<td>'. $row['product_title'] . '</td>';
        echo '<td>'. $row['product_img1']  . '</td>'; 
        echo '</tr>';
    }
    Database::disconnect();
?>

What I want is to make by example $row['brand_id'] a link that redirect to the brand details.

Your TD has to have a hyperlink in it.

echo '<td><a href="URL?brand_id='. $row['brand_id']. '">'. $row['brand_id']. '</a></td>';

with URL?brand_id=... being the URL of the page with the brand details, where you pass your brand_id into.