Some advice:

Your code structure is very hard to follow. It seems to be a muddle of logic and presentation. (Why are the database calls in the middle of the HTML? Why are you using echo to emit the output?)

As a general rule you should perform all logic (such as authentication and fetching data) before worrying about presentation. In a short script this can be accomplished simply, as in the following template:
PHP Code:
<?php
  
# Open session
  
session_start();

  
# Open database connection
  
$dbh mysql_connect(...);
  
#...

  # Fetch data into a variable (say $comments)
  #...
?>
<html>
  <!-- Define HTML markup -->

  <!-- Output the data fetched:  -->
  <?php foreach ($comments as $comment): ?>
    <h2><?php echo $comment['title'?></h2>
    <p><?php echo $comment['comment'?></p>
  <?php endforeach; ?>

  <!-- Any other markup -->
</html>
This type of structure is much easier to follow, easier to maintain, and scales well if your website or web application develops beyond its original level of complexity.