For version 2 of the question:
while($row = $result->fetch_assoc()) {
echo "";
}
echo "<table><tbody><tr><th>ID</th><th>Name</th></tr><tr><td>".$row["repID"]."</td><td>".$row["repName"]." ".$row["repBio"]."</td></tr></tbody></table>";
Print the table header first, then the row contents within the while loop and finally the closing table tags:
echo "<table><tbody><tr><th>ID</th><th>Name</th></tr>";
while($row = $result->fetch_assoc()) {
echo "<tr><td>".$row["repID"]."</td><td>".$row["repName"]." ".$row["repBio"]."</td></tr>";
}
echo "</tbody></table>";
Because you are filtering for a single ID, printing the headers outside the while loop here is not really necessary. But you must access
$row
inside the loop because it is out of scope when using it after the while loop. Even when
$row
is declared outside the loop if would not work because it is
NULL
when the loop has terminated.