combining PHP and HTML
<p>As a newbie, my question is is it good practice to write code like this in PHP, mixing HTML and PHP or is there a better way of doing it</p>

<pre><code>&lt;?php 
    if (isset($_POST['submit']))
    {
        $principal_balance = $_POST['principal_amount'];
        $interest_rate = $_POST['interest_rate'];
        $repayment_amount = $_POST['repayment_amount'];

        echo "&lt;html&gt;";
        echo "&lt;head&gt;";
        echo "&lt;title&gt; Loans &lt;/title&gt;";
        echo "&lt;meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" /&gt;";
        echo" &lt;link rel=\"stylesheet\" type=\"text/css\" href=\"styles/document.css\" /&gt;";
        echo "&lt;body&gt;";


        echo "&lt;table&gt;";
        echo "&lt;th&gt; Principal Balance &lt;/th&gt; &lt;th&gt; Interest Amount &lt;/th&gt; &lt;th&gt; Principal Balance Amount Recovered &lt;/th&gt; &lt;th&gt; Principal Balance &lt;/th&gt; &lt;th&gt; Outstanding Balance &lt;/th&gt;";
        while ($principal_balance &gt; 0)
        {

            if ($principal_balance &lt; $repayment_amount)
            {
                exit;
            }
            else
            {
                $interest_amount = $interest_rate * $principal_balance * 1 / 12;

                $principal_amount_recovered = $repayment_amount - $interest_amount;

                $outstanding_balance = $principal_balance - $principal_amount_recovered;

                round ($interest_amount, 2);
                round ($principal_amount_recovered, 2);
                round ($outstanding_balance, 2);
                //echo $principal_balance . "," . $interest_amount . "," . $principal_amount_recovered . "," . $outstanding_balance . "&lt;br /&gt;";
                echo "&lt;tr&gt; &lt;td&gt;" . round ($principal_balance, 2) . "&lt;/td&gt; &lt;td&gt;" . round ($interest_amount, 2) . "&lt;/td&gt; &lt;td&gt;" . round ($principal_amount_recovered, 2). "&lt;/td&gt; &lt;td&gt;" . round ($outstanding_balance, 2) . "&lt;/td&gt; &lt;/td&gt;";

                $principal_balance = $outstanding_balance;          
            }
        }
        echo "&lt;/table&gt;";
        echo "&lt;/body&gt;";
        echo "&lt;/html&gt;";
    }
?&gt;
</code></pre>
