You can modify this:
<? function select()
{
global $showrecs;
global $page;
global $order;
global $ordtype;
to this
<? function select()
{
global $showrecs, $page, $order, $ordtype;
That goes for all your global variable definitions.
The only MAJOR thing I see is that you're using BOTH early and recent PHP code. Which version are you using? $POST[] replaced $HTTP_POST_VARS[] in PHP 4.1 I believe, possibly later; yet, you use both. Your $username variable is set using the $POST[] array, while ALL OTHER VARIABLES are set using the $HTTP_GET/POST_VARS[] array(s). Choose one, and stick with it.
Secondly, I would suggest removing all the bloat from your page. Split it up so it's easier to work with. Having all the functions in one page makes it really hard to navigate around logically. Take all your functions, put them in a new PHP document, and just include that at the top of the page that will use them.
I'll attach two txt files with how I would lay out your code. It's more free flowing, and easier.
Download them here: Functions.phps & userview.phps
I edited your code only slightly, and went with a more recent version of PHP to script for. I don't see a "form" that the username is submitted to, so I'm not sure what's going on. The only thing I can say, is that when they submit the username, put the username into the session. Something like a little line like this:
$_SESSION['username'] = (isset($_POST['username'])) ? $_POST['username'] : $_SESSION['username'];
$username = (isset($_POST['username'])) ? $_POST['username'] : $_SESSION['username'];
Hope that helps.
~Brett