douhuan1937 2017-03-06 16:38 采纳率: 0%
浏览 14

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

I dont seem to get what I'm doing wrong. This is my code

<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>

and this is supposed to be passed on to my single view page with this code:

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();
    }

but what i get is just a blank URL saying localhost/toresponsive/product.php?productID= where it passes on a blank value

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 关于大棚监测的pcb板设计
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入