echo "\t\t<div class=outerframe>\n";
// Inner table 1: User attributes
echo "\t\t\t\t<table class=leftframe>\n";
echo "\t\t\t\t\t<thead>\n";
echo "\t\t\t\t\t\t<tr>\n";
echo "\t\t\t\t\t\t\t<th>User ID</th>\n";
echo "\t\t\t\t\t\t\t<th colspan=2>" . $myrow['userid'] . "</th>\n";
echo "\t\t\t\t\t\t</tr>\n";
echo "\t\t\t\t\t</thead>\n";
// This function allows for editable fields
detail_row($current_tbl, $myrow['userid'], $myrow['firstname'], 'firstname', $edit_field);
detail_row($current_tbl, $myrow['userid'], $myrow['lastname'], 'lastname', $edit_field);
detail_row($current_tbl, $myrow['userid'], $myrow['department'], 'department', $edit_field);
detail_row($current_tbl, $myrow['userid'], $myrow['extension'], 'extension', $edit_field);
// detail_row($current_tbl, $myrow['userid'], $myrow[user_status], 'user_status', $edit_field);
detail_row($current_tbl, $myrow['userid'], $myrow['active'], 'active', $edit_field);
// Framing. Replace with div?
echo "\t\t\t\t\t</table>\n";
// echo "\t\t\t\t</td>\n";
// echo "\t\t\t\t<td class=outerframe>\n";
// Inner table 2: User Assignments
echo "\t\t\t\t\t<table class=rightframe>\n";
$user_query = "SELECT * FROM asset_tbl a\n\t\t\tLEFT OUTER JOIN pc_detail_tbl ON (pc_assetid=assetid)\n\t\t\tLEFT JOIN (\n\t\t\t\tSELECT DISTINCT ON (assetid_fkey) * FROM assignment_tbl \n\t\t\t\tLEFT JOIN user_tbl ON (userid_fkey=userid)\n\t\t\t\tORDER BY assetid_fkey, datetime desc\n\t\t\t) AS usernames\n\t\t\tON assetid=assetid_fkey\n\t\t\tWHERE userid = '{$userid}'\n\t\t\tORDER BY type ASC, description ASC";
$result = pg_query($user_query);
if (!$result) {
    echo "<pre>Problem with query: " . $user_query . "\n\n";
    echo pg_last_error();
    echo "</pre>";
    exit;
}
echo "\t\t\t\t<thead>\n";
        exit;
    }
    $pc_row = pg_fetch_assoc($pc_result);
    // Build PC Data list
    detail_row($sub_tbl, $asset_row['assetid'], $pc_row['computernumber'], 'computernumber', $edit_field);
    detail_row($sub_tbl, $asset_row['assetid'], $pc_row['videocard'], 'videocard', $edit_field);
    detail_row($sub_tbl, $asset_row['assetid'], $pc_row['videobus'], 'videobus', $edit_field);
    detail_row($sub_tbl, $asset_row['assetid'], $pc_row['cpu'], 'cpu', $edit_field);
    detail_row($sub_tbl, $asset_row['assetid'], $pc_row['harddrive'], 'harddrive', $edit_field);
    detail_row($sub_tbl, $asset_row['assetid'], $pc_row['memory'], 'memory', $edit_field);
    detail_row($sub_tbl, $asset_row['assetid'], $pc_row['batch'], 'batch', $edit_field);
    detail_row($sub_tbl, $asset_row['assetid'], $pc_row['expresscode'], 'expresscode', $edit_field);
    detail_row($sub_tbl, $asset_row['assetid'], $pc_row['warranty'], 'warranty', $edit_field);
    detail_row($sub_tbl, $asset_row['assetid'], $pc_row['mayadongle'], 'mayadongle', $edit_field);
}
detail_row($current_tbl, $asset_row['assetid'], $asset_row['active'], 'active', $edit_field);
echo "\t\t\t</table>\n";
// Framing. Replace with div?
/* 	echo "\t\t\t\t</td>\n";
	echo "\t\t\t\t<td class=outerframe>\n";  */
// Inner table 2: User Assignments
echo "\t\t\t<table class=rightframe>\n";
$assignment_query = "SELECT * FROM asset_tbl \n\t\t\t\tLEFT JOIN assignment_tbl ON (asset_tbl.assetid=assignment_tbl.assetid_fkey)\n\t\t\t\tLEFT JOIN user_tbl ON (assignment_tbl.userid_fkey=user_tbl.userid)\n\t\t\t\t\tWHERE (asset_tbl.assetid='" . $asset_row['assetid'] . "')\n\t\t\t\t\tORDER BY assignment_tbl.datetime DESC";
$assignment_result = pg_query($assignment_query);
if (!$assignment_result) {
    echo "<pre>Problem with query: " . $assignment_query . "\n\n";
    echo pg_last_error();
    echo "</pre>";
    exit;
}
// Get the first row for use with the New User Assignment form