PHP. How to access specific database records and display it into a form
<p>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.  </p>

<p>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.</p>

<pre><code>    &lt;?php        

    // connect to db
    include 'dbConnect.php';

    // Select statement
    $sql = "SELECT * FROM confnames, divnames teaminfo";
    $results = $pdo-&gt;query($sql);

    while($row = $results-&gt;fetch()) {
    ?&gt;
            &lt;tbody&gt;

                                &lt;tr&gt;
                    &lt;td class="team"&gt;&lt;?= $row['teamName'] . $row['nickName'] ?&gt;&lt;/td&gt;
                    &lt;td&gt;10&lt;/td&gt;
                    &lt;td&gt;0&lt;/td&gt;
                    &lt;td&gt;0&lt;/td&gt;
                    &lt;td class="pct"&gt;1.000&lt;/td&gt;
                    &lt;td&gt;6-0-0&lt;/td&gt;
                    &lt;td&gt;4-0-0&lt;/td&gt;
                    &lt;td&gt;3-0-0&lt;/td&gt;
                    &lt;td&gt;8-0-0&lt;/td&gt;
                    &lt;td&gt;355&lt;/td&gt;
                    &lt;td&gt;212&lt;/td&gt;
                    &lt;td class="ptsGreen"&gt;+143&lt;/td&gt;
                    &lt;td class="streak"&gt;Won 10&lt;/td&gt;
                                &lt;/tr&gt;
    }
</code></pre>

<p>In this line:</p>

<pre><code>&lt;td class="team"&gt;&lt;?= $row['teamName'] . $row['nickName'] ?&gt;&lt;/td&gt;
</code></pre>

<p>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.  </p>

<p>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?</p>