title: List all comments and get the username of the author of another table in PHP
body: <p>I'm adding a feedback system to a system of students, the idea is that teachers have access to a list of students and can leave a comment about that student.</p>
  
  <p>Table masters:</p>
  
  <pre><code>id
  username
  </code></pre>
  
  <p>Table comments:</p>
  
  <pre><code>id
  id_master
  id_student
  text
  </code></pre>
  
  <p>Then I go to <code>student.php?id=1</code> show all results in table <code>comments</code>:</p>
  
  <pre><code>&lt;?php
  // See comments student
  function SeeComments($id) { 
   $db = DB::getInstance();
   $query = $db-&gt;query("SELECT * FROM comments WHERE id_student = ?", array($id));
   $results = $query-&gt;results();
   return ($results);
  }
  
  $id = $_GET['id'];
  $Data = SeeComments($id);
  
  foreach ($Data as $v1) {
   echo "&lt;b&gt;Username - Text&lt;/b&gt;&lt;br&gt;";
   echo $v1-&gt;id_master." - ".$v1-&gt;text."&lt;br&gt;";
   echo "---------------------&lt;br&gt;";
  }
  ?&gt;
  </code></pre>
  
  <p>As I can get the <code>username</code> of the table <code>masters</code> to display the results instead of the <code>id</code> like:</p>
  
  <pre><code>echo $v1-&gt;username." - ".$v1-&gt;text."&lt;br&gt;";
  </code></pre>