I am trying to send the product Id of the specific productId via sessions using php enter image description here Like When I click One of these I want to pass the Specific Product Id to my Next Page enter image description here So that I can Display The Data.
<?php
$sql = "SELECT * FROM products ORDER BY RAND() LIMIT 4" ;
$result= mysqli_query($conn,$sql);
while($row = mysqli_fetch_assoc($result)): ?>
<?php
$productId =$row['productId'];
$subCatId = $row['subCatId'] ;
$_SESSION['productId'] = $productId;?> //I TRIED THIS WAY BUT SINCE IT IS ON LOOP THIS SETS THE SESSION VARIABLE TO THE PRODUCT THAT IS DISPLAYED AT THE LAST
<?php
$sql = "SELECT * FROM pictures WHERE productId = $productId ";
$results= mysqli_query($conn,$sql);
if($rows = mysqli_fetch_assoc($results)): ?>
<?php $raw_url = $rows['pic'];
$urli = "uploads/".$raw_url;
<?php endif ?>
I am new to PHP and also have little knowledge on JS. Please Suggest what should I learn to solve this. Thank you!