如何在适当的HTML表中显示PHP变量

Hey guys its my first question here I think.

So I'm using MyBB Forum software.

I have a PHP code that fetches some data from a database no issues in there its working properly.

$query = $db->query("SELECT * FROM housing");
while($result = $db->fetch_array($query))
{    
    $housingvar .= "<td>". $result['username']. "</td>";
    $price .= "<td>". $result['Price']. "</td>";
    $city .= "<td>". $result['City']. "</td>";
    $tax .= "<td>". $result['Tax']. "</td>"; 
    $adrz .= "<td>". $result['Adress']. "</td>";
}

This is the code. I'm using. These variables are then plugged in an HTML table on the forum but everything is in the same column and I dont know how to make a new row for every data. I'm sure this is possible but dont know how.

I cant use echo in my PHP code either. Since I'm using these variables in a pure HTML template.

<tr>
    {$housingvar}
         {$price} 
          {$city}
            {$adrz}
            {$tax}
    </tr>

To create a new row in an HTML table, you use the <tr> tag. I would try the following:

echo "<tr>";
   $price = $result['Price'];
   echo "<td> $price </td>";
    //other code here
echo "</tr>";

<tr> for table row and <td> for table data.
However you have to wrap your while statement with table tag:

$output = "";
$output .= "<table>";
while ($result = $db->fetch_array($query)) {
     // Starting a new table row
     $output .= "<tr>";
        $output .= "<td>".htmlentities($result['username']). "</td>";
        /* Append the rest of the fields */
     // End of row
     $output .= "</tr>";
}
$output .= "</table>";
{ $output }