Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.
It is really personal preference, but the trend is and what seems to be more maintainable is to separate display and logic. So what is commonly done is to do PHP logic related stuff and then include a file that is mostly HTML but has some echos in it as in your second example. This also makes it easier for developers and designers to work together as the files for display are not littered with loops, db queries etc...
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
You then would echo $hello where you needed it. It can also be used to keep code quite tidy I find. Sometimes you have a lot of HTML and a lot of PHP variables and it just is far too long winded to go around opening and closing PHP I think.