Try not to make simple things to complicated. OK, I've been using php for about 4 days now, and noticed that everyone seems to jumble up all the php and the html all smashed together. annoying!!
I've been using coldfusion for YEARS. ASP a bit. DO your LOGIC first, THEN output. It'll make your life so much better.
make your queries, set your variables, work your data at the TOP of a file. then do your html and output variables at the end of the file. its all in one php file, because thats what we're working with. nothing wrong with that. keeping logic seperated for output is extremly helpful for fixing code, makeing changes, or if someone elseever has work on the code.
nothing says annoying coding to me more than a line of 5 or more echos in php doing nothing but outputing html. sometimes it OK to ?> out of php and do your html, then <?php back into it when you need it. Same concepts with asp and cf.
work the data and logic as much as you can, then show results. sometimes you need to mix up html and logic, like with looped outputs and stuff. but moving as much of the php logic as possilble above the html helps clean up code a LOT!
PHP is already way to annoying to look at, this seperation can help, especialy if you learning still.