title: Viewing sizes based on the product ID
body: <p>I am trying to figure out how to display a drop down of sizes dependent on the product id. I have a product tbl which holds information and a productdetails tbl which has a productid as the foreign key, the sizes and units in stock.</p>
  
  <p>I would like to display only the sizes which are available to each particular product. </p>
  
  <p><strong>Product Display Code</strong>         </p>
  
  <pre><code>&lt;?php while ($row = $stmt-&gt;    fetch()) { ?&gt;
  &lt;div class="col-sm-12 col-md-6"&gt;
  &lt;div class="thumbnail"&gt;
  &lt;div class="productimage"&gt;
  &lt;img src="&lt;?= $row['pimage'] ?&gt;" alt="&lt;?= $row['name'] ?&gt;" onclick="window.location.href = '../Controller/Expand.php?id=&lt;?= $row['productid'] ?&gt;'"&gt;   
  &lt;/div&gt;
  &lt;div class="caption"&gt;                        
  &lt;h5&gt;&lt;?= $row['name'] ?&gt;&lt;/h5&gt;
  &lt;h6&gt; &lt;select name="size" id="size"&gt;                               
  &lt;?php foreach ($data as $row): ?&gt;
  &lt;option&gt;&lt;?= $row['size'] ?&gt;&lt;/option&gt;
  &lt;?php endforeach ?&gt;
  &lt;/select&gt;&lt;/h6&gt;
  &lt;br/&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;?php
  }
  ?&gt;
  </code></pre>
  
  <p><strong>Display Shop</strong></p>
  
  <pre><code>   &lt;?php
  
  require_once 'DatabaseConnection.php';
  
  extract($_GET);
    $sql = "SELECT
    Product.name,
    Product.colour,
    Product.unitprice,
    Product.pimage,
    Product.unitweight,
    ProductDetails.unitsinstock,
    ProductDetails.size,
    Product.discount,
    Product.productid,
    ProductDetails.productid
    FROM
    Product,
    ProductDetails
    WHERE
    Product.productid=ProductDetails.productid
    AND
    ProductDetails.unitsinstock&gt;0";
  
    $stmt = $pdo-&gt;prepare($sql) or die(implode(':', $stmt-&gt;errorInfo()));
    $stmt-&gt;execute() or die(implode(':', $stmt-&gt;errorInfo()));
    $cols = $stmt-&gt;columnCount(); 
  </code></pre>
  
  <p><strong>Sizes.Controller</strong></p>
  
  <pre><code>    &lt;?php
      require_once 'DatabaseConnection.php';
      $smt = $pdo-&gt;prepare("SELECT ProductDetails.size, ProductDetails.productid, Product.productid 
  FROM ProductDetails, Product 
  WHERE unitsinstock&gt;0 
  AND ProductDetails.productid=Product.productid");
      $smt-&gt;execute();
      $data = $smt-&gt;fetchAll();
  </code></pre>
  
  <p>Any help would be appreciated! Thanks</p>