Note that there are some explanatory texts on larger screens.

plurals
  1. POGet clicked link, display product in another page
    primarykey
    data
    text
    <p>I populate a product catalog from mysql in a php while loop.. I am trying to make it so that when i click on a product that products information is displayed on another page. So far im trying to use sessions, but it always sends the last product regardless of which one is clicked. I need help!!</p> <p>the catalog.</p> <pre><code>while($row = mysqli_fetch_array($sql)){ $data = $row['image']; $file = substr($data, strpos($data, "/") + 1); echo "&lt;a href='products.php'&gt;", "&lt;div class='productdiv'&gt;", "&lt;div class='productimage'&gt;", "&lt;img class='resizedimage' src='$file' alt='{$row['name']} Image' /&gt;", "&lt;/div&gt;", "&lt;div class='productname'&gt;{$row['name']}&lt;/div&gt;", "&lt;div class='brand'&gt;Brand -&gt; {$row['brand']}&lt;/div&gt;", "&lt;div class='brand'&gt;Code -&gt;{$row['code']}&lt;/div&gt;", "&lt;div class='productprice'&gt;&amp;pound{$row['price']}&lt;/div&gt;", "&lt;/div&gt;", "&lt;/a&gt;"; $_SESSION['name']=$row['name']; $_SESSION['brand']=$row['brand']; $_SESSION['code']=$row['code']; $_SESSION['image']=$file; } </code></pre> <p>And this is where i want to display it on the other page</p> <pre><code>echo "&lt;div class='productcontainer'&gt;", "&lt;div class='productpageimage'&gt;", "&lt;img src='{$_SESSION['image']}' alt='{$_SESSION['name']}' /&gt;", "&lt;/div&gt;", "&lt;div class='productpagename'&gt;", $_SESSION['name'], "&lt;/div&gt;", "&lt;div class='productpagebrand'&gt;", $_SESSION['brand'], "&lt;/div&gt;", "&lt;div class='productpagecode'&gt;", $_SESSION['code'], "&lt;/div&gt;", "&lt;/div&gt;"; ?&gt; </code></pre> <p>Can anyone help? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload