0

I have a website with a series of images of products, and I want to have the functionality that when a user clicks on an image, it redirects to a separate webpage with more information, which is generated on-the-fly via PHP. I'm using sessions to transfer the data.

In determining whether one of the images has been clicked, I am following the advice given here.

However, my isset($_GET['value']) always just returns false. It doesn't get past my for-loop. Here's my code:

  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;

My goal is for it to pass the value of $pcode onto the next webpage.

zh1
  • 231
  • 2
  • 8

0 Answers0