A table is not rendering correctly while I’m trying to retrieve data from a MySQL table. Basically, I use an if statement to see if anything exists (if the user has posted information) and if they have I go to the else condition which displays the data in an HTML table. Here’s the code I’ve started with for the else statement.
else{
//BEGIN JOB POSTING
echo "<table border=1 width=200 height=200>";
while($row_job = mysqli_fetch_array($result_job))
{
echo "<tr>".$row_job['subject']."</tr>";
}
mysqli_free_result($result_job);
echo "</table>";
}
The reason I put the width and height and border is so you can see where the table is rendering and where the actual information is rendering. The information is being displayed, it’s just being displayed side by side with no spaces and not in a <tr>. Here’s a screenshot:

The crazy thing is that if you check the source code of this page it looks like this:
<table border=1 width=200 height=200><tr>twkjljl</tr><tr>lkjljl</tr></table>
But if you inspect the element in Google Chrome, it looks like this:

So I tried a couple things are I changed the code to have them display in <td> and it renders correctly. Here’s that code and screenshot:
else{
//BEGIN JOB POSTING
echo "<table border=1 width=200 height=200><tr>";
while($row_job = mysqli_fetch_array($result_job))
{
echo "<td>".$row_job['subject']."</td><br />";
}
mysqli_free_result($result_job);
echo "</tr></table>";
}

While that’s fine, I want the data to display in different rows not different columns and can’t see where the error in the code is. What in the world is going on?
After
<tr>you need to encapsulate all data in<td>.