PHP $ _GET没有""看"该图片已被点击

时间:2018-04-18 22:41:16

标签: php html

我有一个包含一系列产品图片的网站,我想拥有一个功能,当用户点击图片时,它会重定向到一个单独的网页,其中包含更多信息,这些信息是通过即时生成的PHP。我使用会话来传输数据。

在确定是否已点击其中一张图片时,我会按照here给出的建议。

但是,我的isset($_GET['value'])总是只返回false。它没有超过我的for循环。这是我的代码:

  function show_product($nm, $price, $image, $pcode){
    echo "<h4> $nm at $price </h4>";
    echo "<a href='product_webpage.php?value=$pcode'><img src=$image></a><br>";
   }

$q = "SELECT productName, MSRP, imageFilePath, productCode FROM productsAndServices WHERE productLine = 'Apparel'"; /***** ADJUST THIS FOR PRODUCT LINE ****/
$result = $conn->query($q);
if (!$result) die ($conn->error);

$rows = $result->num_rows;
for ($i=1; $i <= $rows ; $i++){
   $result->data_seek($i-1);
   $arr = $result->fetch_assoc();
   show_product($arr["productName"], $arr["MSRP"], $arr["imageFilePath"], $arr["productCode"]);
}

// Grab product code when user clicks an image


if(isset($_GET['value'])) // this returns false.
{
   $CLICKED_IMG_CODE = $_GET['value'];
} 

// Overwrite this value to a cookie for use in product_webpage.php
$_SESSION['key'] = $CLICKED_IMG_CODE;

我的目标是将$pcode的值传递到下一个网页。

0 个答案:

没有答案