查看购物车问题



我的应用程序的所有其他部分都在工作,但我的用户查看购物车不起作用我不知道是否与索引有关

我试过使用外部 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>   

没有结果 它不会给出任何错误,它仅显示标题部分,我不确定索引。

您的代码中有几个拼写错误。

  • 当我是对的时,最后应该还有另一个"s"吗? cart.email_address=:email_addres
  • <?php echo $product['price']* $prouct['units'];?> 行缺少一个"d"
  • 此时您还错过了"$"符号以及问号后的"php":<?echo product['product_name'];?>

你应该在 php 中将 display_errors 设置为 On.ini并注释掉 error_reporting(0(;出于调试目的:)

问候

您有一个错别字email_addres email_address。

WHERE cart.email_address=:email_addres";
$stmt->bindParam(':email_address',$email_address);

谢谢你们,你们是最好的,你们摇滚了我的编码生活 这是错别字,也是那个我没有放一个

session_start()

初始化 $email_address on 的值

$email_address=$_SESSION['email_address'];

万事如意!

最新更新