title: how to make table using php foreign key
body: <p>I have a question about PHP query.
  I have 2 tables.
  <br/>First Table:</p>
  
  <pre><code>|id_table1 | first_name | last_name |
  |----------|------------|-----------|
  |    1     |    John    |    Doe    |
  |    2     |    Doe     |    John   |
  </code></pre>
  
  <p>Second Table:</p>
  
  <pre><code>|id_table2 | hobby  | age | id_table1|
  |----------|--------|-----|----------|
  |    1     |football| 17  |    1     |
  |    2     |swimming| 18  |    2     |
  </code></pre>
  
  <p>I want to make table like this:</p>
  
  <pre><code>|    John Doe    |       |   Doe John    |
  |----------------|       |--------|------|
  |   Hobby  | Age |       |  Hobby |  Age | 
  |----------|-----|       |--------|------|
  | football | 17  |       |swimming|  19  |
  |basketball| 18  |
  </code></pre>
  
  <p>What is the syntax to make that table in php? May be using foreach, but how?
  Thanks.</p>
  
  <p>The code</p>
  
  <pre><code>&lt;?php
  $ftable="select * from ftable";
  $stable="select * from stable";
  $ftable1= mysqli_query($conn, $ftable);
  $stable1= mysqli_query($conn, $stable);
  foreach ($ftable as $row) {
   echo "
    &lt;tr&gt;
     &lt;th style='text-align: center' colspan='2'&gt;".$row['first_name']."&lt;/th&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
     &lt;th&gt;Hobby&lt;/th&gt;
     &lt;th&gt;Age&lt;/th&gt;
     &lt;/tr&gt;";
  
   foreach ($ftable1 as $row1) {
    echo "
     &lt;tr&gt;
      &lt;td&gt;".$row1['hobby']."&lt;/td&gt;
      &lt;td&gt;".$row1['age']."&lt;/td&gt;
      &lt;tr&gt;";
   }
  }
  ?&gt;
  </code></pre>