【发布时间】:2016-02-16 01:17:54
【问题描述】:
请有人查看此代码并告诉我如何获取可点击的<td> 表的内容?
<?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();
?>
我想要通过示例$row['brand_id'] 制作一个重定向到品牌详细信息的链接。
【问题讨论】:
-
只需使用锚点,创建另一个页面,如
details.php,在href属性中回显它,最简单的是:href="detail.php?id=<echo the brand id here>"。从该详细信息页面中,只需使用该 ID 来选择您选择的特定行,之后您将不得不自己编写代码 -
没问题,你还没试过。只需在您的字符串中添加 HTML 锚点
标签: php html variables html-table