Filter Data based on Username



Hello-

After logging in a user, I want to display data relevant to that user
on my page. Like YTD sales and Goals, etc...

The only data that is showing up where the dynamic text is, is for the
1st record in my table.

SELECT * FROM XTR WHERE username = 'username'

shouldn't the only information accessible be that of the users?

<?php
$username_xtr2 = "-1";
if (isset($_POST['username'])) {
$username_xtr2 = (get_magic_quotes_gpc()) ? $_POST['username'] :
addslashes($_POST['username']);
}
mysql_select_db($database_xcomm, $xcomm);
$query_xtr2 = sprintf("SELECT * FROM xtr WHERE %s = '%s'",
$username_xtr2,$username_xtr2);
$xtr2 = mysql_query($query_xtr2, $xcomm) or die(mysql_error());
$row_xtr2 = mysql_fetch_assoc($xtr2);
$totalRows_xtr2 = mysql_num_rows($xtr2);
?>

//dynamic text:

<?php echo $row_xtr2['firstname']; ?>

How do I add the filter?

TIA-

.