A very easy to do this is to write all the HTML, then just write the php code within the html, for example:
<?
php code here
?>
<table>
<tr>
<td>
<? echo $var; ?>
</td>
</tr>
</table>
<?
carry on with php here;
?>
It saves a lot of hassle and bug checking for escape characters, quotes all that kind of stuff that occurs when using PHP to output HTML.