In the PHP manual, it states you really don't need to close a connection to free resources because it will flush the resources after the script executes anyhow with newer versions of PHP. (unless you use the pconnect; the persistent connection.) Just look in the manual for the mysql_close() command for more info.
At any rate, it doesn't hurt to close the connection anyhow, so I usually just do it at the end of my page (right after the HTML tag) That way, I know my connection remains persistent at least through that page session.
As long as you wait to close the connection until after you do all of your querying, you should be fine. Once you store the variables, you don't need to keep the connection, you can close it.
Just be sure to assign a variable to the connection so you can close it later.
I'm sure some of the other more established users have their own opinions... This is just my own.
Jacob