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

使用PHP将ID从动态项页面传递到动态单个页面,php,Php,我似乎不明白我做错了什么。这是我的密码 <div class="product"> <div class="productLabels"> <a href="product.php?productID=<?php $id; ?>"> <img class="productImage" src="<?php echo $row[4]; ?>"> <p style="fon

我似乎不明白我做错了什么。这是我的密码

<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();
    }
但我得到的只是一个空白URL,上面写着localhost/toresponsive/product.php?productID=
当它传递一个空白值时

您忘记在href@Roljhon我已经试过了,但是仍然不起作用。如果$id变量不是空的,那么它应该可以起作用。尽管如此,这是我看到这个问题的唯一原因。@Roljhon我很抱歉,我不得不重新检查。它正在工作。表示了解的语句。即使是这样也不安全!