I am trying to build a site that will display every NFL team, sort them by conference and division, and then display various season stats for them. I have a database built that has three tables: conference names, division names, and team info(name and season stats). I cannot do anything different for the database since this is a class assignment and I can't have any hard coding. I need to access the database to display all of this information into the HTML form that has been built.
I am having a hard figuring out how to pull specific information information from the database in order to display in the various parts of the table. Here is some of the code I have so far.
<?php
// connect to db
include 'dbConnect.php';
// Select statement
$sql = "SELECT * FROM confnames, divnames teaminfo";
$results = $pdo->query($sql);
while($row = $results->fetch()) {
?>
<tbody>
<tr>
<td class="team"><?= $row['teamName'] . $row['nickName'] ?></td>
<td>10</td>
<td>0</td>
<td>0</td>
<td class="pct">1.000</td>
<td>6-0-0</td>
<td>4-0-0</td>
<td>3-0-0</td>
<td>8-0-0</td>
<td>355</td>
<td>212</td>
<td class="ptsGreen">+143</td>
<td class="streak">Won 10</td>
</tr>
}
In this line:
<td class="team"><?= $row['teamName'] . $row['nickName'] ?></td>
I need to be able to pull one record from the teaminfo table and the teamName and nickName columns. For example I have the first record in the teaminfo table set to the Green Bay teamName and the Packers nickName. I need to display this specific information that specific spot and then do it again with the following team a little lower and so on and so forth until I have all 32 teams and their data displayed.
I have been having a hard time figuring out how I could do this without needing to re-write the sql statement and information before every single line where I need to display the information. Do you guys have any ideas?