我有一个 PHP 页面,它是产品列表,如下所示。最后一列是指向报告该产品所有详细信息的单个产品页面的链接。
ID | Title | LINKTOPAGE
-------|--------------|------------------
001 | ProductTitle | $ID(001)-->Link to the single_product_page.php
002 | ProductTitle | $ID(002)-->Link to the single_product_page.php
003 | ProductTitle | $ID(003)-->Link to the single_product_page.php
上表由以下循环生成:
<?php
while ($row = mysqli_fetch_array($risultato)){
echo '<tr>
<td>'.$row['id'].'</td>
<td>'.$row['post_title'].'</td>
<td>'.'LinkToSinglePage >>'.'</td>
</tr>';
}?>
我已经准备好从该查询中检索数据的单个页面:
SELECT
p.id as ID,
p.post_title,
p.post_status,
p.post_excerpt as shortdesc,
p.post_content as longdesc
FROM mg_posts as p
WHERE p.ID= 13323
GROUP BY p.ID
我想做的是将“linktoProductPaGe”链接到单个页面。如果我没记错的话,我应该将 ID=13323 替换为存储列表中所选产品 ID 的变量。
有什么建议吗?
最佳答案
你可以这样做,例如(获取方法):
产品列表(products_lists.php):
<?php
while ($row = mysqli_fetch_array($risultato)){
echo '<tr>
<td>'.$row['id'].'</td>
<td>'.$row['post_title'].'</td>
<td>single_product_page.php?product_id='.$row['id'].'</td>
</tr>';
}?>
并且在您的产品详细信息页面 (single_product_page.php) 中,您可以获得这样的 ID:
<?php $product_id = $_GET['product_id']; ?>
希望对您有所帮助。 :-)
关于php - Mysql/Php - 显示从列表中选择的单个产品页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45660894/