使用PHP将ID从动态项目页面传递到动态单页面

时间:2017-03-06 16:38:18

标签: php

我似乎无法得到我做错的事。这是我的代码

<div class="product">
     <div class="productLabels">
        <a href="product.php?productID=<?php $id; ?>"> <img class="productImage" src="<?php echo $row[4]; ?>">
            <p style="font-style: italic; font-weight: bold;"><?php echo $row[1]; ?></p>
            <p>PHP <?php echo $row[2]; ?></p>
        </a>
    </div>
</div>

这应该使用以下代码传递到我的单个视图页面:

if (isset($_GET['productID'])) {
        $id = $_GET['productID'];
        $id = preg_replace('#[^0-9]#i', '', $_GET['productID']);
        $query = "SELECT * FROM tblproducts WHERE productID='$id' LIMIT 1";
        $result_set = mysqli_query($con, $query);
        $productCount = mysqli_num_rows($result_set);

        if ($productCount > 0) {
            while ($row = mysqli_fetch_row($result_set)) {
                $id = $row[0];
                $productName = $row[1];
                $price = $row[2];
                $description = $row[3];
                $image = $row[4];
                $category = $row[5];

        ?>
        <div class="singleViewContainer">
            <h2 class="header"><?php echo $productName; ?> | PHP <?php echo $price; ?></h2>
            <div class="base">
                <img src="<?php echo $image; ?>">
                <div class="specs">
                    <p style="font-weight: bold">Specifications, Features and Description: </p>
                    <p><?php echo $description;  ?></p>
                    <button class="add" type="submit">ADD TO CART</button>
                </div>
                <div class="notice">
                    <p>Standard Delivery will arrive in 3-5 business days</p>
                    <p>Cash on delivery available for items below PHP3000</p>
                    <p>- Always inquire for stock availability. Some items are order basis from the supplier <br>- Cheque payments are subject to 3 banking days clearing <br>- 30% downpayment is required for order basis/reservation<br>- Prices are exclusive of VAT and credit card surcharges<br>- Images posted are for reference only. Actualy product may vary<br>- Prices and specifications may change without prior notice</p>
                </div>
            </div>      
        </div>
        <?php
            }
        } else {
            echo "That item does not exist";
        }

    } else {
        echo "Data to render the page is missing";
        exit();
    }

但我得到的只是一个空白的网址,说localhost / toresponsive / product.php?productID = 传递空白值的地方

0 个答案:

没有答案