title: How to retrieve and display data from another table
body: <p>I have 2 tables</p>
  
  <p>Table (1): 'games' with column names of 'games_id', 'home_team_fk', 'away_team_fk', etc.</p>
  
  <p>Table (2): 'teams' with column names of 'teams_id', 'teams_name', etc.</p>
  
  <p>'home_team_fk' = 'teams_id'</p>
  
  <p>Currently my statement will only retrieve the 'teams_id'. This is my current code. I want to generate an SQL statement that will display the 'teams_name' instead of the 'home_team_fk'.</p>
  
  <pre><code>&lt;?php
  $season = $_GET['season'];
  $stmt = $DBcon-&gt;prepare("SELECT * FROM games WHERE games_season = '$season'");
  $stmt-&gt;execute();
  ?&gt;
  
  &lt;?php if($stmt-&gt;rowCount() &gt; 0) { while($row=$stmt-&gt;FETCH(PDO::FETCH_ASSOC)) { ?&gt;   
  
  &lt;?php print($row['home_team_fk']); ?&gt; vs &lt;?php print($row['away_team_fk']); ?&gt;
  
  &lt;?php } } else { ?&gt;
  
  No games recorded yet.
  
  &lt;?php } ?&gt;
  </code></pre>