title: PHP get all matching rows in relational mysql innodb database
body: <p>I have made 3 tables in a DB with a many to many relationship. for variable <code>$refernece_keys</code> in my DB should return all of the related fields in the DB - but it is only returning the first assigned and ignoring the others.</p>
  
  <p><code>e.g. page1 should return keys_href: id's 1, 2, 3, 4, 8, 10, 15 - however it only returns id:1
       page2 should return keys href: id's 3, 4, 5, 7, 8, 11 - however it only returns id:3</code></p>
  
  <p>Is there something wrong with my ARRAY?</p>
  
  <pre><code>$SQL = 
     "SELECT  * FROM learn_more AS lm 
  
  LEFT JOIN  learn_more_to_reference_key AS lmtrk 
          ON  lm.id = lmtrk.learn_more_id 
  
  LEFT JOIN  reference_keys AS rk 
          ON  rk.keys_id = lmtrk.reference_key_id
  
       WHERE  lm.page_title = '$this_page'";
  
  $result = mysql_query($SQL) or die(mysql_error()); 
  
   while ($db_field = mysql_fetch_array($result))
  {   
          $id                =     $db_field['id'];
          $main_title        =     $db_field['main_title'];
          $main_content     =     $db_field['main_content'];
          $reference_keys   =     $db_field['keys_href']; 
          $sub_title        =     $db_field['sub_title'];
          $sub_content      =     $db_field['sub_content'];
  }
  </code></pre>
  
  <p>------------------------------------------------>EDIT</p>
  
  <p>My PHP view page is a template</p>
  
  <pre><code>&lt;div id="content"&gt;  
  &lt;div class="section_frame"&gt;
  
  
  &lt;div class="section_title"&gt;
  &lt;?php echo $main_title; ?&gt;
  &lt;/div&gt;
  
  &lt;div class="section_content"&gt;
  &lt;?php echo $main_content; ?&gt;
  &lt;/div&gt;
  
  
  &lt;div class="section_content_ref"&gt;
  &lt;span class="hl_reference"&gt;&lt;u&gt;key references:&lt;/u&gt;&lt;/span&gt; 
  &lt;?php echo $reference_keys; ?&gt;
  &lt;/div&gt;
  
  &lt;div class="sub_section_title"&gt;
  &lt;?php echo $sub_title; ?&gt;
  &lt;/div&gt;
  
  &lt;div class="sub_section_content"&gt;
  &lt;?php echo $sub_content; ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>so basically i just want my values to echo out.. </p>