title: Pick items from while loop php
body: <p>For a school project I have to make a simple webshop.
  To display my featured products on the hopepage I used a while loop. But now I want to add a shoppingcart. So after you pressed the button add to cart the right data has to be picked and display on another page. I will do that with cookies. So all I need is to get the right data in a variable.</p>
  
  <p>I tried to use the result right away but that didn't work.</p>
  
  <pre><code>&lt;?php
    $sql = "SELECT * FROM product WHERE featured = 1 AND nr_available &gt; 0";
    $resultquery = $conn-&gt;query($sql);
  
  
  ?&gt;
  
  &lt;div class="preview"&gt;
    &lt;?php while ($result = mysqli_fetch_assoc($resultquery)) : ?&gt;
    &lt;div class="productpreview"&gt;
      &lt;div class="previewheader"&gt;
        &lt;img src="images/products/&lt;?=$result['picture']; ?&gt;" class="previewimg" style="max-width: 300px;"&gt;
      &lt;/div&gt;
      &lt;div class="description"&gt;
        &lt;h2&gt;&lt;?=$result['title']; ?&gt;&lt;/h2&gt;
        &lt;p&gt;&lt;?=$result['description']; ?&gt;&lt;/p&gt;
        &lt;p&gt;Size: &lt;?=$result['size']; ?&gt;&lt;/p&gt;
        &lt;p&gt;Price: € &lt;?=$result['price']; ?&gt;&lt;/p&gt;
        &lt;button class="add" onclick="window.location.href='buy.php'"&gt;Buy&lt;/button&gt;
        &lt;button class="add" onclick="window.location.href='shoppingcart.php'"&gt;Add to cart&lt;/button&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;?php endwhile; ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I want to store the right data in variables which I can display on another page.</p>