How can the issue of repeating table headers in each new row be addressed when outputting data in a table using PHP?

When outputting data in a table using PHP, the issue of repeating table headers in each new row can be addressed by using the <th> tag for the table headers and the <td> tag for the table data. By placing the table headers outside of the loop that generates the table rows, the headers will only be displayed once at the top of the table.

&lt;table&gt;
  &lt;tr&gt;
    &lt;th&gt;Header 1&lt;/th&gt;
    &lt;th&gt;Header 2&lt;/th&gt;
    &lt;th&gt;Header 3&lt;/th&gt;
  &lt;/tr&gt;
  &lt;?php
    // Loop to output data rows
    foreach ($data as $row) {
      echo &quot;&lt;tr&gt;&quot;;
      echo &quot;&lt;td&gt;&quot; . $row[&#039;data1&#039;] . &quot;&lt;/td&gt;&quot;;
      echo &quot;&lt;td&gt;&quot; . $row[&#039;data2&#039;] . &quot;&lt;/td&gt;&quot;;
      echo &quot;&lt;td&gt;&quot; . $row[&#039;data3&#039;] . &quot;&lt;/td&gt;&quot;;
      echo &quot;&lt;/tr&gt;&quot;;
    }
  ?&gt;
&lt;/table&gt;