使用php和sql创建购物车

时间:2017-03-28 15:09:57

标签: php

我正在尝试在我的网站上为estore创建购物车系统,但我无法正常工作。我开始创建一个文件来显示我的数据库产品,但它们没有显示出来。它应该显示每个产品的名称,价格和描述,但它只是说出名称,价格和描述而不是实际信息。这是代码:

<?php
session_start();
include ('config.php');
$itemCount = 0;

if(isset($_SESSION['cart']));

$itemCount= count (isset($_SESSION['cart']) ? $_SESSION['cart'] : array()    );
 }
     ?>

  <html>

 <head>

 </head>

 <ul>
   <li><a href="index1.php">Home</a></li>
   <li><a href="cart1.php">View cart</a></li>
    <li> { <?php echo $itemCount; ?>  }  </li>

   </ul>


    <p class= "msg">

    <?php if(isset($_REQUEST['msg'])) {
        switch($_REQUEST['msg']):

        case 'add':

            $msg = $_REQUEST['p'] . " was added to your cart.";

        break;

        endswitch;

        echo $msg;

   }
    ?>

    <h2>Products</h2>
     <ul>
     <li>Name</li>
     <li>Price</li>
    <li>Description</li>
     </ul>



    <?php 

    $prod =mysql_query($db, "SELECT * FROM 'Products' ");


while($r = mysql_fetch_array($db)){
    extract($r);

    ?>

    <div>

   <div class="inline-pr"><?=$productName?></div>
   <div class="inline-pr"><?=$price?></div>

</div>

</body
</html>

0 个答案:

没有答案