在表中,我想要链接 a,单击转到其他页面并选择此类别中的所有产品 我想放一个,但我不知道怎么做,因为从数据库中选择的 td 可以是多个
$sql = 'SELECT categorie.id,name,username FROM categorie,user
where user.id = categorie.added_by ';
$result = $mysqli->query($sql);
?>
<table class="data-table">
<h1>Categorie List<h1>
<thead>
<tr>
<th>Id</th>
<th>Username</th>
<th>Added By</th>
</tr>
</thead>
<tbody>
<?php
if($result == false)echo "errrrr";
else{
while ($row = mysqli_fetch_array($result))
{
echo '<tr>
<td>'.$row['id'].'</td>
// here i want link <a> when click go to other page and
// select all products in this categorie
<td>'.$row['name'].'</td>
<td>'.$row['username'].'</td>
</tr>';
}
}
?>
</tbody>
</table>
在表格中,我想要链接a,点击转到其他页面并选择此类别中的所有产品
最佳答案
您的链接应该是这样的:
...
<td><a href="otherpage.php?categorie='.$row['id'].'">'.$row['name'].'</a></td>
...
然后在otherpage.php中,您可以从$_GET['categorie']
获取类别ID。
关于php - 从数据库中选择数据到 html 表并链接到其他页面 (<a>),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46553048/