title: select data from two tables, return data and get product name from item id
body: <pre><code>&lt;?php
  $transactionOutput = "";
  $sql = mysql_query("SELECT * FROM transactions WHERE emailaddress='$email'");
  $productCount = mysql_num_rows($sql);
  if($productCount &gt; 0) {
  while($row = mysql_fetch_array($sql)) {
      $item_id = $row["item_id"];
      $quantity = $row["quantity"];
      $size = $row["size"];
      $price = $row["price"]; 
  
      $sql = mysql_query("SELECT * FROM products WHERE id='$item_id'");
      $productCount = mysql_num_rows($sql);
      while($row = mysql_fetch_array($sql)) {
      $product_name = $row["product_name"];
      }
  
      $transactionOutput .= "&lt;tr&gt;";
      $transactionOutput .= "&lt;td align='center'&gt;" .$product_name. "&lt;/td&gt;";
      $transactionOutput .= "&lt;td align='center'&gt;" .$quantity. "&lt;/td&gt;";    
      $transactionOutput .= "&lt;td align='center'&gt;" .$size. "&lt;/td&gt;";
      $transactionOutput .= "&lt;td align='center'&gt;" .$price. "&lt;/td&gt;";
      $transactionOutput .= "&lt;/tr&gt;";
  }
  
      } else {
  $transaction_list = "You have made no transactions yet";
  }
  
  
  ?&gt;
  </code></pre>
  
  <p>I'm trying to access data from two different tables and then return the product name of each item by matching the id in the product table with the item_id returned from the transactions table. This does output the correct information however it only shows the first transaction and no others, i know this is also probably horribly programmed too</p>