 <p>This is the string you are printing:</p> <pre><code>"&lt;td&gt; £ $first_number = {$row['bcosts']}; $second_number = {$row['rcosts']}; $third_number = {$row['value']}; $sum_total = $third_number - $second_number - $first_number; print ($sum_total); &lt;/td&gt; "; </code></pre> <p>The variables get replaced with their values:</p> <pre><code>"&lt;td&gt; £ = 100; = 25; = 300; = - - ; print (); &lt;/td&gt; "; </code></pre> <p>And the browser converts multiple whitespace characters into one space when displaying.</p> <p>You cannot calculate stuff during inside the string. This should fix it:</p> <pre><code>"&lt;td&gt; £"; $first_number = $row['bcosts']; $second_number = $row['rcosts']; $third_number = $row['value']; $sum_total = $third_number - $second_number - $first_number; print ($sum_total); echo "&lt;/td&gt; "; </code></pre>