购物车按钮不起作用

时间:2018-05-29 04:43:07

标签: php mysql

嗨我在编码时遇到了一些问题。当我必须将我的编码结构从div更改为表格时添加到购物车按钮不起作用。当它在div中时工作但是我已经更改为表格购物车按钮而不是工作请帮我解决我的问题..

以下代码是旧的(div),在这里正常工作..

 <?php if($microproduct['nr']){?>
               <div class="product-box">
                    <div class="list" id="micropro">
                            <?php foreach ($microproduct['result'] as $resultmicroproduct){ ?> 
                                <div class="row">
                                <div class="col-md-3">
                                  <img src="images/feature-two-one.png" class="img-fluid mx-auto d-block">
                                </div>
                              <div class="col-md-7">
                                  <div class="pro-desc">
                                    <h5><?php echo $conn->stripval($resultmicroproduct['microsoft_product_legalname']);?></h5>
                                    <p>Part number: <?php echo $conn->stripval($resultmicroproduct['microsoft_product_partnumber']);?></p>
                                    <p>Item Name: <?php echo $conn->stripval($resultmicroproduct['microsoft_product_name']);?></p>
                                    <p>Product family: <?php echo $conn->stripval($resultmicroproduct['microsoft_product_family']);?></p>
                                    <h4><i class="fa fa-rupee"></i> <?php echo $conn->stripval($resultmicroproduct['microsoft_product_price']);?></h4>
                                  </div>
                                </div>
                                <div class="col-md-2">
                                  <div class="wrapper-div">
                                    <input min="1" type="number" name="quantity<?php echo $resultmicroproduct['microsoft_product_id'] ?>" class="form-control" id="quantity" value="1" autocomplete="off">
                                    <br>
                                    <?php $postvalue = base64_encode(json_encode($resultmicroproduct)); ?>
                                     <input type="hidden" name="type" value="microsoft_product">
                                    <button class="btn btn-dark btn-sm add_to_cart"  id="<?php echo $resultmicroproduct['microsoft_product_id'] ?>" >Add to Cart</button>
                                  </div>
                                </div> 
                            </div>
                            <?php } ?>
                    </div>
                </div>
                <?php } ?>

以下代码是新的(表格)购物车按钮不起作用..

<table id="example" class="table table-striped table-bordered" style="width:100%">
                <thead>
                    <tr>
                        <th>Image</th>
                        <th>Product Description</th>
                        <th>Quantity & Cart</th>
                    </tr>
                </thead>
                <?php if($microproduct['nr']){?>
                <tbody>
                    <?php foreach ($microproduct['result'] as $resultmicroproduct){ ?>  
                    <tr class="product-box">  
                        <td><img src="images/feature-two-one.png" class="img-fluid mx-auto d-block"></td>
                        <td>
                          <div class="pro-desc">
                            <h5><?php echo $conn->stripval($resultmicroproduct['microsoft_product_legalname']);?></h5>
                            <p>Part number: <?php echo $conn->stripval($resultmicroproduct['microsoft_product_partnumber']);?></p>
                            <p>Item Name: <?php echo $conn->stripval($resultmicroproduct['microsoft_product_name']);?></p>
                            <p>Product family: <?php echo $conn->stripval($resultmicroproduct['microsoft_product_family']);?></p>
                            <h4><i class="fa fa-rupee"></i> <?php echo $conn->stripval($resultmicroproduct['microsoft_product_price']);?></h4>
                          </div>
                        </td>
                        <td>
                          <div class="wrapper-div">
                            <input min="1" type="number" name="quantity<?php echo $resultmicroproduct['microsoft_product_id'] ?>" class="form-control" id="quantity" value="1" autocomplete="off">
                            <br>
                             <input type="hidden" name="type" value="microsoft_product">
                            <button class="btn btn-dark btn-sm add_to_cart" id="<?php echo $resultmicroproduct['microsoft_product_id'] ?>">Add to Cart</button>
                          </div>
                        </td>
                    </tr>  
                    <?php } ?>
                </tbody>
                <?php } ?>
                <tfoot>
                    <th>Image</th>
                    <th>Product Description</th>
                    <th>Quantity & Cart</th>
                </tfoot>
        </table>

1 个答案:

答案 0 :(得分:0)

您甚至没有form

<form action ="?" method="?">
  //your inputs and submit
</form>

如果您没有定义要做什么,您期望会发生什么?