【发布时间】:2018-07-31 08:58:25
【问题描述】:
我正在做一个项目,我们在数据库中有一些项目显示在网站上,并且运行良好的代码如下:
<form method="post" action="store.php?action=add&ItemNo=<?php echo $products['ItemNo']; ?>">
<a href="product.php"><div class="products">
<img src="<?php echo $products['img'];?>" class="img-responsive"/>
<!-- this connects to the database and gets the image of item -->
<h4><?php echo $products['ItemName'];?></h4>
<h3>$ <?php echo $products['Price'];?></h3>
<input type="text" name="Quantity" class="form-control" value="1"/>
<!-- This creates an box where the default qnt is set to 1 -->
<input type="hidden" name="ItemName" value="<?php echo $products['ItemName']; ?>" />
<input type="hidden" name="Price" value="<?php echo $products['Price']; ?>" />
<input type="submit" name="addtocart" style="margin-top:5px;" class="btn btn-info"
value="Add to Cart"/>
<!-- this creates the btn that adds item to cart -->
</div>
</a>
</form>
现在我正在尝试展示有关每种产品的更多详细信息。我想要的只是当用户单击任何项目时,他们将被发送到item.php 页面,其中将有关于该特定项目的更多详细信息。
此时我在 item.php 中显示了所有信息,但我被卡住了。
我不知道如何表达这个问题,也许这就是我在 Google 上找不到任何帮助的原因。我是 PHP 新手,因为我几周前才开始接触它。
【问题讨论】:
-
你有一个带有列表的页面和一个带有特定的页面吗?您需要一种技术将其组合成一个结果。您可以立即显示一个弹出窗口(我不推荐),将数据上传到 iframe(我也不推荐),发送带有 id 的整个表单(不带排序选项),显示详细信息(特别不推荐),立即加载数据并通过几个(例如
jQuery ('#id-product') show())显示它们(我不推荐大量结果列表)或使用AJAX(甚至websocket)加载数据。从编程科学的角度来看,你应该练习所有的方法。