【发布时间】:2018-12-22 01:19:59
【问题描述】:
我正在创建购物网站,现在我有一个表调用产品,其中存储了所有产品数据,并且我有不同的表购物车,其中存储了所有添加到购物车的产品,所以基本上在购物车中我存储了 productid, userid 所以现在在名为 checkout 的页面上,我想检索数据,我们将从购物车表中获取特定登录用户的 productid,并且从表 products 我们将显示添加到购物车的所有产品,所以基本上从购物车表中我们将获取添加到购物车和餐桌产品的产品,我们将展示它们。现在的问题是我已经检索到数据,但它只显示一个项目而不是多个项目。提前致谢
这是我的代码:
<?php $userid = $_SESSION['userSession'];
require_once 'dbconfig.php';
$stmt = $DB_con->prepare('SELECT cartid,userid,productid FROM cart WHERE userid =:uid');
$stmt->execute(array(':uid'=>$userid));
if($stmt->rowCount() > 0)
{
while($rows=$stmt->fetch(PDO::FETCH_ASSOC))
{
extract($rows);
{
}
?>
<?php
$productid = $rows['productid'];
require_once 'dbconfig.php';
$stmt = $DB_con->prepare('SELECT productid,productname,productcategory,producttype,productprice,productimage1 FROM products WHERE productid = :uid');
$stmt->execute(array(':uid'=>$productid));
if($stmt->rowCount() > 0)
{
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
extract($row);
{
}
?>
<div class="bs-example4" data-example-id="simple-responsive-table">
<div class="table-responsive">
<table class="table-heading simpleCart_shelfItem">
<tr>
<th class="table-grid">Item</th>
<th>Prices<h3></h3></th>
<th >Delivery </th>
<th>Subtotal</th>
</tr>
<tr class="cart-header1">
<td class="ring-in"><a href="single.html" class="at-in"><img src="thumb/<?php echo $row['productimage1']; ?>" class="img-responsive" alt=""></a>
<div class="sed">
<h5><a href="single.html"><?php echo $row['productname']; ?></a></h5>
</div>
<div class="clearfix"> </div>
<div class="close2"> </div></td>
<td>₹ <?php echo $row['productprice']; ?></td>
<td>FREE SHIPPING</td>
<td class="item_price">$100.00</td>
<td class="add-check"><a class="item_add hvr-skew-backward" href="#">Add To Cart</a></td>
</tr>
</table>
</div>
</div>
<div class="produced">
<a href="single.html" class="hvr-skew-backward">Produced To Buy</a>
</div>
</div>
</div>
<?php
}
}
else
{
?>
<div class="col-xs-12">
<div class="alert alert-warning">
<span class="glyphicon glyphicon-info-sign"></span> No Data Found ...
</div>
</div>
<?php
}
?> <?php
}
}
else
{
?>
<div class="col-xs-12">
<div class="alert alert-warning">
<span class="glyphicon glyphicon-info-sign"></span> No Data Found ...
</div>
</div>
<?php
}
?>
【问题讨论】: