You are seeing the raw php code on the web page because you don't actually have an opening <?php tag at the start of that php code. The opening <?php tag that you do have, is immediately being closed on the same line, then is never being opened again.
In addition to the misspelling of localhost that Weedpacket pointed out, you have single-quotes around the table name in the sql query, making it a literal string, rather than a table name (identifier), you apparently don't have any () around the ->query() method call, which will produce a php syntax error once you correct the php opening/closing tags, and you haven't converted the mysql_fetch... or mysql_close statements.
Also, don't echo static html markup. This is a huge waste of typing. Just drop out of php 'mode' when you have a bunch of html that contains no php code.