这是index.php的一部分。此代码用于显示数据库中的所有产品。如何从数据集(PHP)传递正确的ID?
while($row = mysqli_fetch_array($result)) {?>
<form action="product.php?>" method="post">
<tr class="info">
<td align="center"><h3><?php echo $row['name'];?></h3></td>
</tr>
<tr class="success">
<td align="center"><div class="grow pic"><img src="uploads/<?php echo $row['image'];?>"></div></td>
</tr>
<tr class="info">
<td><?php echo substr($row['description'],0,75);?></td>
</tr>
<tr class="success">
<td align="center"><input name="cart" type="submit" value="More Details"></td>
</tr>
<tr>
<td></td>
</tr>
</form>
<?php
}
?>
还有一个页面叫做product.php。当用户单击index.php中的“更多详情”按钮时,它将重定向到product.php。
我想要做的是,当用户点击“更多详细信息”按钮时,我需要传递该页面的正确产品ID。怎么做?
添加一个(隐藏)表单字段,其中包含值? – jeroen
表单中的要点是什么?只需添加一个标准锚并添加一个产品唯一标记的GET参数,例如该ID,例如product.php?id = idhere –
使用隐藏字段并传递您的ID。 –