应用程序的所有其他部分都在工作,但是我的用户查看购物车不工作,我不知道是否与索引有关
我尝试使用外部php
<!DOCTYPE html>
<html>
<head>
<title>View table</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs /popper.js/1.14.7/umd/popper.min.js"></script>
</head>
<body>
<table class="table">
<thead>
<tr>
<th scope="col">Item</th>
<th scope="col">brand</th>
<th scope="col">flavour/type</th>
<th scope="col">quantity</th>
<th scope="col">Number of units</th>
<th scope="col">Number of packets</th>
<th scope="col">price</th>
<th scope="col">Cost</th>
<th scope="col">Picture</th>
<th scope="col">D</th>
</tr>
</thead>
<tbody>
<?php
require_once("config.php");
error_reporting(0);
$email_address=$_SESSION['email_address'];
$sql="SELECT product_name ,brand,flavour_type,quantity,number_of_units,price ,units,image_path
FROM gokcen.product NATURAL JOIN gokcen.cart
WHERE cart.email_address=:email_addres";
$stmt=$db->prepare($sql);
$stmt->bindParam(':email_address',$email_address);
$stmt->execute();
$result=$stmt->fetchAll();
foreach($result as $product)
{
?> <tr>
<td><?php echo $product['product_name'];?></td>
<td><?php echo $product['brand'];?></td>
<td><?php echo $product['flavour_type'];?></td>
<td><?php echo $product['quantity'];?></td>
<td><?php echo $product['number_of_units'];?></td>
<td><?php echo $product['units'];?></td>
<td><?php echo $product['price'];?></td>
<td><?php echo $product['price']* $prouct['units'];?></td>
<td> <img src="pics/<?php echo $product['image_path'];?>" width="80" height="80"/></td>
<td><a href="deletefromcart.php?item=<?echo product['product_name'];?>"> delete <a></td>
</tr>
<?php }?>
</tbody>
</table>
<a href="#" class="btn btn-primary" >Buy</a>
</body>
</html>
没有结果它没有给出任何错误,它只显示标题部分,而且我不确定索引。
答案 0 :(得分:1)
您的代码中有几种错字。
cart.email_address=:email_addres
<?php echo $product['price']* $prouct['units'];?>
行缺少一个“ d” <?echo product['product_name'];?>
您应该在php.ini中将display_errors设置为On,并注释掉error_reporting(0);。用于调试:)
问候
答案 1 :(得分:0)
您有一个错字email_addres电子邮件地址。
WHERE cart.email_address=:email_addres";
$stmt->bindParam(':email_address',$email_address);
答案 2 :(得分:0)
谢谢你们,你们是我摇滚生涯中最好的,这是错别字,还有 我没有放
session_start()
要初始化$ email_address的值
$email_address=$_SESSION['email_address'];
祝一切顺利!