title: PHP match 2 selected table
body: <p>I've to select 2 table from mysql. After select the data from query and I would to to match for this 2 table. Code is in below</p>
  
  <pre><code>echo "&lt;table&gt;";
  
  foreach($tableA as $tableA){
      echo "&lt;tr&gt;";
      echo "&lt;td&gt;" . $tableA['ID'] . "&lt;/td&gt;";
      echo "&lt;td&gt;" . $tableA['Name'] . "&lt;/td&gt;";
      echo "&lt;td&gt;" . $tableA['Date'] . "&lt;/td&gt;";
  
      // Start a new table for description    
      echo "&lt;td&gt;&lt;table&gt;"; 
      foreach($tableB as $tableB){                    
          if ($tableA['ID'] = $tableB['ID']){
              echo "&lt;td&gt;" . $tableB['Item'] . "&lt;/td&gt;";
          }
          else {
              // do nothing
          }
      }               
      echo "&lt;/table&gt;&lt;/td&gt;";
      echo "&lt;/tr&gt;";
  }
  echo "&lt;/table&gt;";
  </code></pre>
  
  <p>Table A</p>
  
  <pre><code>ID  Name    Date
  1   Test 1  1/01/2014
  2   Test 2  2/01/2014
  3   Test 3  3/01/2014
  4   Test 4  4/01/2014
  5   Test 5  5/01/2014
  </code></pre>
  
  <p>Table B</p>
  
  <pre><code>ID  Item
  1   Tomato
  1   Orange
  2   Apple
  2   Watermelon
  3   Honeydrew
  4   Pineapple
  4   Durian
  5   Grape
  </code></pre>
  
  <p>From this 2 table A and B, I select from query, but from the PHP codeigniter View, how can match this 2 table to below sample table? Please help.
  Join the data:</p>
  
  <pre><code>ID  Name    Date        Item
  1   Test 1  1/01/2014   Tomato
                          Orange
  2   Test 2  2/01/2014   Apple
                          Watermelon
  3   Test 3  3/01/2014   Honeydrew
  4   Test 4  4/01/2014   Pineapple
                          Durian
  5   Test 5  5/01/2014   Grape
  </code></pre>